refactor: Replace SortableJS 2/4: replace SortableJS with native HTML5 drag & drop for column header reorder - #1242
Open
6pac-ai wants to merge 2 commits into
Open
refactor: Replace SortableJS 2/4: replace SortableJS with native HTML5 drag & drop for column header reorder#12426pac-ai wants to merge 2 commits into
6pac-ai wants to merge 2 commits into
Conversation
… removal - overwrite the @4tw/cypress-drag-drop drag command with a native HTML5 DnD event sequence (pointerdown/mousedown -> dragstart -> dragenter/ dragover -> drop -> dragend) sharing one DataTransfer, so the same command drives SortableJS today and a native drag engine later - add characterization specs for plain header reorder (unorderable columns, onColumnsReordered payload, resizing unorderable columns), frozen-grid reorder (cross-boundary lock, scroll preservation, auto-scroll) and header-to-dropzone grouping drops - part 1 of the SortableJS removal (port of slickgrid-universal #2634) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… header reorder Port of slickgrid-universal's column reorder engine (ghiscoding/slickgrid-universal#2634) adapted to this repo. The grid no longer needs SortableJS for header column reordering; the SlickDraggableGrouping plugin still uses it (to be ported next), so the dependency itself stays for now. - add `setupColumnReorderDrag()` to slick.interactions.ts: native HTML5 drag with live DOM reordering during dragover, browser-edge auto-scroll, Firefox/Linux mouse fallback, touch fallback with a manual drag ghost, and dropzone hooks for draggable grouping - rewire slick.grid.ts: drop the sortablejs type imports and Sortable instances, add a column-map reconciliation in onDragEnd so `hidden` and `reorderable: false` columns keep their original indices (the old toArray() read-back silently dropped hidden columns on any reorder) - two deliberate deviations from the upstream engine, both preserving the previous SortableJS behavior pinned by the characterization specs: - reorders are constrained to the dragged column's own header container, so columns can never cross the frozen-column boundary - the drag finalizes on `drop` as well as `dragend` (SortableJS finalized on drop; without this, drag sources that skip dragend leave the DOM reordered without setColumns/onColumnsReordered ever running) - enable the hidden-column characterization test (fixed by the column-map reconciliation) - remove a redundant spec-level @4tw/cypress-drag-drop import in example-grid-menu.cy.ts that re-registered the plugin's drag command over the shared HTML5 DnD overwrite Full Cypress suite: 600/601 passing (1 intentional pending), lint and TS declaration build clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Part 2 of the SortableJS removal (port of slickgrid-universal's refactor(core)!: drop SortableJS dependency #2634). Stacked on #1240 — the characterization specs landed there pass unchanged against this new engine; that was the acceptance gate for this PR.
After this PR the grid itself no longer uses SortableJS for header column reordering. The
SlickDraggableGroupingplugin still does (next PR), so the dependency and the example<script>tags stay for now.What's in here
src/slick.interactions.ts— newsetupColumnReorderDrag(): native HTML5 drag & drop with live DOM reordering duringdragover, browser-edge auto-scroll, a Firefox/Linux mouse-based fallback (native HTML5 drag is broken there), a touch fallback with a manual drag ghost (touch screens never fire HTML5 drag events), and dropzone hooks that the draggable-grouping port will use. Registered on theSlicknamespace so iife/browser builds keep working with no new<script>tag (every example already loadsslick.interactions.js).src/slick.grid.ts— sortablejs type imports and the two Sortable instances removed;setupColumnReorder()rewired onto the new engine with a column-map reconciliation inonDragEnd:hiddenandreorderable: falsecolumns keep their original indices. This fixes a latent bug — the oldtoArray()read-back silently dropped hidden columns from the grid on any reorder (hidden columns render no header, so the DOM read-back omitted them).src/models/interactions.interface.ts(+ColumnReorderDragOption),src/global.d.ts(Slick namespace typing),src/styles/slick.grid.scss(fallback drag-ghost rule).@4tw/cypress-drag-dropimport inexample-grid-menu.cy.tsis removed (it re-registered the plugin'sdragcommand over the shared HTML5 DnD overwrite from test(cypress): Replace SortableJS 1/4: characterize column header reorder ahead of SortableJS removal #1240).Deliberate deviations from the upstream engine
Both preserve the previous SortableJS behavior that the #1240 characterization specs pin:
dropas well asdragend— SortableJS finalized on drop. Without this, drag sources that dispatchdropwithout a followingdragendleave the header DOM visually reordered whilesetColumns()/onColumnsReorderednever run.Not in here
dist/**is intentionally not rebuilt in this PR (release commits regenerate it).package.jsonand in the example pages until the DraggableGrouping port and the final removal sweep.Verification
onColumnsReorderedpayloads, scroll preservation, edge auto-scroll, cross-boundary lock, grouping pill drags and header→dropzone drop (still SortableJS-driven in the plugin).npm run lintandnpm run build:types(strict TS) clean.dist/browser/slick.grid.jscontains no SortableJS references after the change; the only remainingSortable.createcall sites in the bundles come fromslick.draggablegrouping.ts.Next up: port
SlickDraggableGroupingoff SortableJS (setupDropzonePillDrag), then remove the dependency and sweep the ~100 example pages.🤖 Generated with Claude Code