Skip to content

fix: support multiple classes in drag state options - #2485

Open
xiaoyao-666-coder wants to merge 1 commit into
SortableJS:masterfrom
xiaoyao-666-coder:fix/multiple-state-classes
Open

xiaoyao-666-coder wants to merge 1 commit into
SortableJS:masterfrom
xiaoyao-666-coder:fix/multiple-state-classes

Conversation

@xiaoyao-666-coder

Copy link
Copy Markdown

Passing more than one class in a state option such as chosenClass: 'bg-blue-100 opacity-50' throws InvalidCharacterError when dragging starts because toggleClass passes the whole string to DOMTokenList.add.

Split class names on whitespace and add or remove each non-empty token individually. The fallback for elements without classList also handles the tokens separately and keeps repeated additions from creating duplicates. The shared helper covers chosenClass, ghostClass, dragClass, and fallbackClass.

Fixes #2443.

Validation:

  • All three new regression tests fail against the original source and pass with this change. They cover whitespace and repeated class names, the path without classList, and a real fallback drag with multiple classes on the item and clone, including cleanup after drop.
  • The full TestCafe suite and local compatibility suite pass: 23 tests in headless Microsoft Edge 157 on Windows.
  • npm run build passes, including ESM, UMD, and minification. Generated bundles are excluded from the PR as required by the contribution guidelines.

TestCafe was run with --hostname 127.0.0.1 and a separate browser profile for the local environment. No test runner or dependency changes are included.

AI assistance: Codex assisted with the implementation and regression tests; the results above were verified locally.

This branch has not been deployed

No deployments
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.

Multple classes aren't allowed in chosenClass

1 participant