Semantic-ui: [Dropdown] Input Order Should Reflect "Set Selected" Order

Created on 17 Mar 2016  路  14Comments  路  Source: Semantic-Org/Semantic-UI

http://jsfiddle.net/czw7zy25/1/

The select order should reflect the "set selected" array order, it doesn't - instead it's listed in the order of the options.

This makes it very unpredictable, especially with sortSelect set to true.

Enhancement Evaluating Bug / Change

Most helpful comment

This bug is real. It needs a patch.

All 14 comments

This same issue applies in the situation where the dropdown input has initial values, for example:

<input name="numbers" multiple type="hidden" value="162,16,136,129">

The dropdown will sort them in the order that they're provided in the markup. This is a problem where, for example, I want the dropdown _choices_ to be alphabetically sorted, but I want the _selection_ (e.g. values, labels) to be in the exact order that they're provided.

Any workarounds to this issue?

Any Update or workaround for this issue?

It is blocking to implement my requirement as well, where i need to get the selected values of multi select dropdown in the same order as user selected.

Thanks,

The reason is due to this code which sets selected by iterating through the declared options and tests for matches against the set options.

A possible fix here would be to iterate through the set options and test for matches against the declared options instead.

@staff0rd You are right, I've debugged the issue and the first part of the problem is that they loop the items instead of the passed values. Another issue is that the jquery add method which is used adds values in the order that they appear in the dom.

I could try to add a pull request but I'm not really familiar with the code.

Eventually worked around this, you can call the set selected if you first add or move the options to the select in the order that you want them to appear and then refresh the dropdown.

Not happy but it works: http://jsfiddle.net/czw7zy25/3/

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

This bug is real. It needs a patch.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

bump!

This is a bug, especially for multiple search, when user input label the label moves to arbitrary position of label list

I'm also working on something where the order of the selection is important and to be preserved. This is fine when the list is modified while the page is loaded, but when the dropdown is first rendered with an initial value, it reorders the item and displays them lexicographically sorted, as others have mentioned.

Note that the set selected workaround only works if there isn't already a default value.

I worked around by set one by one value, not all in the array

@huypn1106 Yeah, there are some workarounds that work... but it shouldn't be needed.

I'm going to switch away from semantic and fomantic, nothing is being updated and pull requests are not being merged.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

miguelmota picture miguelmota  路  3Comments

batata004 picture batata004  路  3Comments

rdzidziguri picture rdzidziguri  路  3Comments

davialexandre picture davialexandre  路  3Comments