Commit 449d048
committed
bug symfony#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 symfony#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 order2 files changed
+84
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | | - | |
199 | 198 | | |
200 | 199 | | |
201 | 200 | | |
202 | | - | |
203 | 201 | | |
204 | 202 | | |
205 | 203 | | |
| |||
216 | 214 | | |
217 | 215 | | |
218 | 216 | | |
219 | | - | |
| 217 | + | |
220 | 218 | | |
221 | 219 | | |
222 | 220 | | |
| |||
250 | 248 | | |
251 | 249 | | |
252 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
253 | 285 | | |
254 | 286 | | |
255 | 287 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
| |||
47 | 51 | | |
48 | 52 | | |
49 | 53 | | |
50 | | - | |
| 54 | + | |
51 | 55 | | |
52 | 56 | | |
53 | 57 | | |
| |||
158 | 162 | | |
159 | 163 | | |
160 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
161 | 206 | | |
162 | 207 | | |
163 | 208 | | |
| |||
420 | 465 | | |
421 | 466 | | |
422 | 467 | | |
423 | | - | |
424 | | - | |
425 | | - | |
| 468 | + | |
426 | 469 | | |
427 | | - | |
428 | 470 | | |
429 | 471 | | |
430 | 472 | | |
431 | | - | |
432 | 473 | | |
433 | 474 | | |
434 | 475 | | |
435 | 476 | | |
436 | | - | |
| 477 | + | |
437 | 478 | | |
438 | 479 | | |
439 | 480 | | |
| |||
453 | 494 | | |
454 | 495 | | |
455 | 496 | | |
456 | | - | |
457 | | - | |
| 497 | + | |
458 | 498 | | |
459 | 499 | | |
460 | 500 | | |
| |||
0 commit comments