-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace jquery ui's sortable with Sortable.js #2523
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work. I really appreciate the usage of vanilla JavaScript instead of jQuery (a dependency we might of thinking removing as well somewhere in the future)
🚀
61b8460
to
f22c4f3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks John
This feature doesn't work well. It requires using "Tab" to get focus on an item in the list. After doing that it allows pressing up/down to reorder the list. This feature isn't discoverable to users, so I doubt it has ever been used. It also doesn't exist in any of our other sortable tables in the admin. It could just as be implemented using Sortable.js, which we are moving to from jquery-ui's sortable, but I would not rather not spend the time reimplementing something that doesn't work well and isn't consistent with the rest of the admin. If we want this we need to implement is across all of our sortable lists.
f22c4f3
to
411c603
Compare
As per #2469, we are looking to remove jquery ui from the admin.
I initially tried to use html5sortable which is nice and very minimal (2KB min+gz). However, I was unable to get it to work satisfactorily on the taxon tree page. There were also minor issues sorting tables (it would get confused if the rows were dragged too far #right).
I ended up using Sortable.js, which is a little heavier (6KB min+gz), but we get a lot from that. Everything just worked without additional code from us (which even jquery ui sortable needed to fix some problems). Sortable's behaviour should also be more user friendly: it shown nice "ghost" placeholders to where the element is to be dropped, supports touch events, supports scrolling the page, and even animations (which I didn't enable, but worth trying in the future).
This PR starts with some housekeeping:
backend/admin.js
into it's own file,backend/components/sortable_table.js
taxons.js.coffee
, the "Display order" page, to plain JS (see Clarify that we prefer new files to be in JS, not coffee #2376 for justification)taxonomy.js.coffee
, the "taxon tree" page, to plain JSBefore converting the three places jquery-ui/sortable was used:
sortable_table.js
This is the last piece of the puzzle for #2469 "Replace jQuery UI".