Skip to content

fix dom order#1041

Open
xJuvi wants to merge 4 commits into
orchidjs:masterfrom
xJuvi:fix-order
Open

fix dom order#1041
xJuvi wants to merge 4 commits into
orchidjs:masterfrom
xJuvi:fix-order

Conversation

@xJuvi

@xJuvi xJuvi commented May 22, 2026

Copy link
Copy Markdown
Contributor

This PR add a new option to maintain the HTML/DOM order.

At the moment, tom-select adds all selected items at the end in the dom. This is not a bug, it's a feature. With this feature, the users sees on the select input the right order in which the options are selected. The problem is, when using optgroups, the dom is broken because the options inside an optgroup leaving the group and will be placed at the end of the list.

With this PR i implement these changes:

  • When select is in single mode (only one option is selectable), the order will be kept. Users can only see one option and no order is required
  • When select is not in single mode and the new parameter keepOrder is false, the current behavior still exists.
  • When select is not in single mode and the new parameter keepOrder is true, the DOM will keep the correct order but the user see the selection options in order given by DOM.

This PR:
fixes #1040
fixes #938

@xJuvi xJuvi marked this pull request as draft May 22, 2026 10:30
@xJuvi xJuvi marked this pull request as ready for review May 22, 2026 11:24
@NicolasCARPi

Copy link
Copy Markdown
Collaborator
2026-05-22T11:33:10.0417540Z SUMMARY:
2026-05-22T11:33:10.0418289Z ✔ 324 tests completed
2026-05-22T11:33:10.0418826Z ✖ 1 test failed
2026-05-22T11:33:10.0419317Z 
2026-05-22T11:33:10.0419584Z FAILED TESTS:
2026-05-22T11:33:10.0420081Z   API
2026-05-22T11:33:10.0420840Z     clear()
2026-05-22T11:33:10.0422061Z       ✖ 69 - should create empty option and el.value should be empty after clear() on single
2026-05-22T11:33:10.0423092Z         Chrome Headless 148.0.0.0 (Linux 0.0.0)
2026-05-22T11:33:10.0424026Z       AssertionError: expected 'a' to be empty
2026-05-22T11:33:10.0424906Z           at Context.<anonymous> (test/tests/api.js:800:12)

(have to open raw log to see it because here interface is broken https://productionresultssa12.blob.core.windows.net/actions-results/61c786a8-6d7d-4461-b807-a38f067dc30e/workflow-job-run-aa80a7e3-d6d7-50a8-97b9-927696a2cc20/logs/job/job-logs.txt?rsct=text%2Fplain&se=2026-05-22T12%3A37%3A50Z&sig=zLnveMUHco7EtjMl8bhxSIJVM4brfKQPtL3wX4Nz0js%3D&ske=2026-05-22T15%3A25%3A45Z&skoid=ca7593d4-ee42-46cd-af88-8b886a2f84eb&sks=b&skt=2026-05-22T11%3A25%3A45Z&sktid=398a6654-997b-47e9-b12b-9515b896b4de&skv=2025-11-05&sp=r&spr=https&sr=b&st=2026-05-22T12%3A27%3A45Z&sv=2025-11-05)

@xJuvi

xJuvi commented May 22, 2026

Copy link
Copy Markdown
Contributor Author

@NicolasCARPi I saw this and have to check why the tests are failing.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Regression in 2.6.0 from 993 [Bug]: selected options lose their optgroup when option hideSelected:false

2 participants