Created attachment 1603452 [details] The multiselect dropdown shows "<None>" in the list of selected items Description of problem: Multiselect dialog dropdown allows you to select "<None>". If you continue to select other options, it will include "<None>" in the list... "<None>, One, Two". I would not expect "<None>" to be shown. Functionally, it does not affect the array of the chosen options... you would end up with ["One", "Two"] in your array. This also occurs in the Self Service Portal. Version-Release number of selected component (if applicable): 5.11.0.18 How reproducible: Every time Steps to Reproduce: 1. Create a Multiselect dropdown using the default "One, Two, Three" values. 2. Add dialog to catalog item, I used a generic catalog item 3. Order the new item 4. Go to your multiselect dropdown and choose the value "<None>" 5. Select additional options and notice that the displayed list of choices includes "<None>" Actual results: Expected results: I would not expect "<None>" to be displayed in the list of selected options Additional info:
This is a backend bug.. The select only shows the options coming in .values from the server. Request: /api/service_dialogs/68?resource_action_id=5636&target_id=58&target_type=service_template The relevant bits of the field response: type: "DialogFieldDropDownList" data_type: "string" default_value: "[]" dynamic: false options: {sort_by: "description", sort_order: "ascending", force_multi_value: true} values: Array(4) 0: (2) [null, "<None>"] 1: (2) ["1", "One"] 2: (2) ["3", "Three"] 3: (2) ["2", "Two"] For some reason, the server started sending a "<None>" option for multiselects, even though it's not in the dialog definition. Dialog editor has sent values: [["1", "One"], ["3", "Three"], ["2", "Two"]] to the server.
https://github.com/ManageIQ/manageiq/pull/19148
New commits detected on ManageIQ/manageiq/master: https://github.com/ManageIQ/manageiq/commit/42b528bfbdb97aa2d7e3610c79fb470552c19e36 commit 42b528bfbdb97aa2d7e3610c79fb470552c19e36 Author: Martin Hradil <mhradil> AuthorDate: Wed Aug 14 09:00:16 2019 -0400 Commit: Martin Hradil <mhradil> CommitDate: Wed Aug 14 09:00:16 2019 -0400 DialogFieldDropDown - Don't add_nil_option to values for multiselects We're doing `add_nil_option` when computing field `.values`. This probably makes sense for all the other sorted items, but multiselects already have an implicit "Nothing selected" option. And adding "<None>" to `.values` just means it will get shown as another option in the multiselect, allowing the user to select "<None>, One, Two" :). => Explicitly not adding nil for multiselects. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1740823 app/models/dialog_field_drop_down_list.rb | 4 + app/models/dialog_field_sorted_item.rb | 6 +- 2 files changed, 9 insertions(+), 1 deletion(-) https://github.com/ManageIQ/manageiq/commit/618d991694d401f64c52c68a71a44146e77538cf commit 618d991694d401f64c52c68a71a44146e77538cf Author: Martin Hradil <mhradil> AuthorDate: Thu Aug 15 15:30:30 2019 -0400 Commit: Martin Hradil <mhradil> CommitDate: Thu Aug 15 15:30:30 2019 -0400 DialogFieldDropDown spec - multiselect values should not contain <None> fails on master: 1) DialogFieldDropDownList#values when the dialog_field is not dynamic when the raw values are already set and this is a multiselect returns the raw values without a nil option Failure/Error: expect(dialog_field.values).to eq([%w(potato potato)]) expected: [["potato", "potato"]] got: [[nil, "<None>"], ["potato", "potato"]] (compared using ==) Diff: @@ -1,2 +1,2 @@ -[["potato", "potato"]] +[[nil, "<None>"], ["potato", "potato"]] # ./spec/models/dialog_field_drop_down_list_spec.rb:389:in `block (6 levels) in <top (required)>' 2) DialogFieldDropDownList#values when the dialog_field is not dynamic when the raw values are not already set and this is a multiselect returns the values Failure/Error: expect(dialog_field.values).to eq([%w(original values)]) expected: [["original", "values"]] got: [[nil, "<None>"], ["original", "values"]] (compared using ==) Diff: @@ -1,2 +1,2 @@ -[["original", "values"]] +[[nil, "<None>"], ["original", "values"]] # ./spec/models/dialog_field_drop_down_list_spec.rb:457:in `block (6 levels) in <top (required)>' only single selects should have the <None> value https://bugzilla.redhat.com/show_bug.cgi?id=1740823 spec/models/dialog_field_drop_down_list_spec.rb | 40 +- 1 file changed, 36 insertions(+), 4 deletions(-)
New commit detected on ManageIQ/manageiq/ivanchuk: https://github.com/ManageIQ/manageiq/commit/4412053c6ebf143cb20caf97c172fd933605b24b commit 4412053c6ebf143cb20caf97c172fd933605b24b Author: Brandon Dunne <bdunne> AuthorDate: Tue Aug 20 16:49:05 2019 -0400 Commit: Brandon Dunne <bdunne> CommitDate: Tue Aug 20 16:49:05 2019 -0400 Merge pull request #19148 from himdel/multiselect-nil DialogFieldDropDown - Don't add_nil_option to values for multiselects (cherry picked from commit f4eee89877b02c4979bd082b1427d298904a7712) https://bugzilla.redhat.com/show_bug.cgi?id=1740823 app/models/dialog_field_drop_down_list.rb | 4 + app/models/dialog_field_sorted_item.rb | 6 +- spec/models/dialog_field_drop_down_list_spec.rb | 40 +- 3 files changed, 45 insertions(+), 5 deletions(-)
Verified in Version 5.11.0.21.20190821214526_b0060d0