Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dropdown] - Add "set exactly" behavior #2689

Closed
fpayer opened this issue Jul 21, 2015 · 7 comments
Closed

[Dropdown] - Add "set exactly" behavior #2689

fpayer opened this issue Jul 21, 2015 · 7 comments
Milestone

Comments

@fpayer
Copy link

fpayer commented Jul 21, 2015

Expected
The Dropdown should remove existing selected values in the dropdown and replace them with the new ones.

Result
The Dropdown does not set the selected options and appends the newly selected values to the current selection.

Testcase
https://jsfiddle.net/gaa545jc/8/

Notes
Calling "clear" prior to calling "set selected" works as a temporary solution. However, there seems to be some weird effects on "get value" after calling "clear" and "set selected"

@jlukic
Copy link
Member

jlukic commented Jul 21, 2015

set selected is meant to add a value as selected, and does not clear. This is how it is used internally so this behavior can't be changed.

However clear does appear to have a bug where values set while a label is animating out of view, fail to be set correctly. #2690

@jlukic jlukic added this to the 2.0.6 milestone Jul 21, 2015
@fpayer
Copy link
Author

fpayer commented Jul 21, 2015

Ok, I would also recommend updating the description of "set selected" in the docs because the description would lead devs to believe it overwrites any previous value.

@jlukic
Copy link
Member

jlukic commented Jul 21, 2015

I can easily add $('.dropdown').dropdown('set exactly', ['foo', 'baz']); which does clear and then set selected

@fpayer
Copy link
Author

fpayer commented Jul 21, 2015

Yes, that would be a great solution. Much appreciated.

@jlukic jlukic changed the title [Dropdown] - Set selected on a multi dropdown does not remove old selection [Dropdown] - Add "set exactly" behavior Jul 21, 2015
@jlukic
Copy link
Member

jlukic commented Jul 21, 2015

I'm also seeing a related bug when using <select> when nothing is selected (via clear), value will report '', which will trigger selection on placeholder value="" and cause the array to have an improper leading comma, i.e. ,VT,VA

@jlukic
Copy link
Member

jlukic commented Jul 21, 2015

This is actually really fascinating, setting a multi value to '' will then retrieve its value with .val() as [''] if there is a matching option.

jlukic added a commit that referenced this issue Jul 21, 2015
@jlukic jlukic closed this as completed Jul 21, 2015
@cashsun
Copy link

cashsun commented Dec 7, 2017

Hi, I think there's a bug in 'set exactly' - the selected labels are not in the same order of passed array.

i.e. $dropdown.dropdown('set exactly', ['d', 'a','c', 'b']);
result: the multiselect shows 'a', 'b', 'c', 'd' as selected, in that order. Which is not exactly 'set exactly'....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants