Add native x-for reactivity support to @alpinejs/sort #4708
serhumanos
started this conversation in
3. Feature Ideas
Replies: 1 comment
-
|
There is an open PR refactoring x-for in a manner that supports sort as well as increases performance. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, the official @alpinejs/sort plugin does not work reactively with x-for. When elements are reordered via drag-and-drop, the underlying data array bound to x-for is not automatically updated, breaking Alpine.js’s core reactivity model.
As a result, developers are forced to implement manual workarounds—such as listening to the @EnD event, reading the new DOM order, and reconstructing the array by hand. While these hacks may function temporarily, they are fragile, verbose, and contradict Alpine’s declarative and simplicity-first philosophy, and keeps showing errors and warnings.
Moreover, this issue has been repeatedly raised across community discussions and GitHub threads, and all existing solutions rely on similar fragile patches—none offer a robust, officially supported integration.
It would be a significant improvement if @alpinejs/sort included native support for automatically syncing drag-and-drop reordering with the x-for array, so that UI changes immediately reflect in the component’s data state—without any manual intervention. This would not only resolve a common pain point but also align the plugin fully with Alpine.js’s design principles.
Thank you very much
Beta Was this translation helpful? Give feedback.
All reactions