You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #1825 [Autocomplete] Fix grouped options order (zavarock, smnandre)
This PR was merged into the 2.x branch.
Discussion
----------
[Autocomplete] Fix grouped options order
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| Issues | Fix#1616 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License | MIT
The bug is being caused by TomSelect not preserving the order of the option elements in the select as we select the options in the dropdown. In this case, the MutationObserver callback uses the optgroup element as a parameter to "store" the group (if any) to which the option belongs. However, once the option is selected, it no longer has an optgroup as its parentElement (a problem caused by the aforementioned bug).
As I see it, there is no need to "store" the option's group since, in any case, all <option> elements usually have a unique [value], and even if not, it will still work as expected.
A callback was added for options added through [addOption](https://github.com/orchidjs/tom-select/blob/69180fa9e79060060f1824fbde85537579d0005d/src/tom-select.ts#L1636), but the caveat is that it needs the parameter user_created=true to trigger the 'option_add' event.
Commits
-------
4344a3c Yarn cleanup
07b3eeb Build up to date packages
6424bd4 [Autocomplete] Fix grouped options order
0 commit comments