Skip to content

ENG-3680: migrate admin-ui drag-and-drop from react-dnd to dnd-kit#8169

Merged
gilluminate merged 4 commits into
mainfrom
gill/ENG-3680/migrate-dnd-kit
May 15, 2026
Merged

ENG-3680: migrate admin-ui drag-and-drop from react-dnd to dnd-kit#8169
gilluminate merged 4 commits into
mainfrom
gill/ENG-3680/migrate-dnd-kit

Conversation

@gilluminate
Copy link
Copy Markdown
Contributor

@gilluminate gilluminate commented May 12, 2026

Ticket ENG-3680

Description Of Changes

Standardizes admin-ui drag-and-drop on @dnd-kit/*, dropping the second drag library (react-dnd + react-dnd-html5-backend) and removing the root <DndProvider> wrapper that came with it. This also gets us keyboard-accessible reorder (Tab → Space → Arrow keys → Space) on the two existing drag-and-drop spots — column-settings reordering and the access-policies row reordering — which react-dnd didn't provide. The jest.mock("react-dnd", ...) blocks scattered across test files (workarounds for react-dnd's ESM parse issues under Jest) are deleted; dnd-kit doesn't have that problem.

The reorder UX is preserved end-to-end: column-settings still drags by the handle and reorders the visible list; the access-policies table still does its two-phase "update local order on hover, fire onReorder API only on drop / revert on cancel" flow, just routed through <DndContext>'s onDragOver / onDragEnd / onDragCancel instead of react-dnd's useDrag / useDrop.

Code Changes

  • clients/admin-ui/package.json + clients/package-lock.json — added @dnd-kit/core, @dnd-kit/sortable, @dnd-kit/utilities; removed react-dnd and react-dnd-html5-backend.
  • clients/admin-ui/src/pages/_app.tsx — dropped the root <DndProvider backend={HTML5Backend}> wrapper and its imports. dnd-kit is context-per-<DndContext>, no global provider needed.
  • clients/admin-ui/src/features/common/table/column-settings/DraggableColumnListItem.tsx — rewrote with useSortable({ id }). The drag handle gets the sensor attributes / listeners so only the icon initiates drag (preserves the existing UX where the row is the visual hover target but only the icon is grabbable).
  • clients/admin-ui/src/features/common/table/column-settings/DraggableColumnList.tsx — wraps the list in <DndContext> (with PointerSensor + KeyboardSensor using sortableKeyboardCoordinates) and <SortableContext> (verticalListSortingStrategy). useEditableColumns is now id-based: moveColumn(activeId, overId) does an arrayMove keyed on the column ids that dnd-kit hands back, and setColumnVisible(id, isVisible) matches by id rather than index.
  • clients/admin-ui/src/features/access-policies/PoliciesTable.tsx — replaced the local <DndProvider> + DraggableRow with a single <DndContext> around the table and a SortableRow slotted in via components.body.row. onDragOver updates the local visible order using arrayMove (one source of truth for the row order during drag), onDragEnd fires the API only if the position actually changed, and onDragCancel resets the visual state.
  • clients/admin-ui/cypress/e2e/datamap-report.cy.ts — split the existing "should reorder columns" test into two cases — via mouse drag (cypress-real-events realMouseDown + 20 small realMouseMove(0, -10) steps + realMouseUp + drop-animation wait + realClick on save) and via keyboard (focus the handle → SpaceArrowUp × 2 → Space). Both share pre-save modal-order and post-save table-order + reload-persistence assertions.
  • 8 test files — deleted jest.mock("react-dnd", () => ({ useDrag, useDrop, DndProvider })) blocks:
    • src/features/privacy-requests/events-and-logs/__tests__/EventLog.test.tsx
    • src/features/connector-templates/__tests__/SaaSVersionModal.test.tsx
    • src/features/integrations/__tests__/VersionHistoryTab.test.tsx
    • src/features/integrations/configure-tasks/components/__tests__/PrivacyRequestFieldPicker.test.tsx
    • src/features/common/dataset/__tests__/DatasetReferencePicker.test.tsx
    • __tests__/features/common/form/LlmModelSelector.test.tsx
    • __tests__/features/asset-reporting/AssetReportingPage.test.tsx
    • __tests__/features/asset-reporting/AssetReportingTable.test.tsx

Steps to Confirm

The two production drag-and-drop spots are column-settings (inside the Data map report's "Edit columns" modal) and the access-policies row table.

  1. Column settings — mouse: Data map report → ⋯ menu → Edit columns. Drag any column by its handle icon up/down. Order updates live. Click Save → table thead reflects the new column order; reload → order persists.
  2. Column settings — keyboard: same modal, Tab to a drag handle → Space to pick up → ↑/↓ to move → Space to drop. Save and reload as above.
  3. Access policies — mouse: Settings → Access policies (table view). Drag a row by its handle. The row reorder is visible immediately, but the reorder API only fires on drop (not on every hover crossing). Drop in the same spot, or press Esc mid-drag → no API call; visual state reverts.
  4. Access policies — keyboard: Tab to a row's drag handle → Space → Arrow Up/Down → Space. Same API-on-drop-only semantics.

Pre-Merge Checklist

  • Issue requirements met
  • All CI pipelines succeeded
  • CHANGELOG.md updated
    • Add a db-migration This indicates that a change includes a database migration label to the entry if your change includes a DB migration
    • Add a high-risk This issue suggests changes that have a high-probability of breaking existing code label to the entry if your change includes a high-risk change (i.e. potential for performance impact or unexpected regression) that should be flagged
    • Updates unreleased work already in Changelog, no new entry necessary
  • UX feedback:
    • All UX related changes have been reviewed by a designer
    • No UX review needed
  • Followup issues:
    • Followup issues created
    • No followup issues
  • Database migrations:
    • Ensure that your downrev is up to date with the latest revision on main
    • Ensure that your downgrade() migration is correct and works
      • If a downgrade migration is not possible for this change, please call this out in the PR description!
    • No migrations
  • Documentation:
    • Documentation complete, PR opened in fidesdocs
    • Documentation issue created in fidesdocs
    • If there are any new client scopes created as part of the pull request, remember to update public-facing documentation that references our scope registry
    • No documentation updates required

Standardize on @dnd-kit across admin-ui to drop the second drag library,
remove the root <DndProvider>, get keyboard-accessible reorder, and delete
the jest.mock("react-dnd", ...) workarounds carried in 5 test files.
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
fides-plus-nightly Ready Ready Preview, Comment May 15, 2026 7:51pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
fides-privacy-center Ignored Ignored May 15, 2026 7:51pm

Request Review

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 12, 2026

Dependency Review

The following issues were found:
  • ✅ 0 vulnerable package(s)
See the Details below.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA 10c2abe.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

  • clients/admin-ui/package.json
  • clients/package-lock.json

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 12, 2026

Title Lines Statements Branches Functions
admin-ui Coverage: 9%
6.93% (3173/45767) 6.32% (1676/26480) 4.79% (650/13544)
fides-js Coverage: 78%
79.17% (1977/2497) 66.25% (1249/1885) 73.31% (349/476)
privacy-center Coverage: 85%
82.53% (364/441) 79.74% (189/237) 74.07% (60/81)

@gilluminate gilluminate marked this pull request as ready for review May 12, 2026 23:11
@gilluminate gilluminate requested a review from a team as a code owner May 12, 2026 23:11
@gilluminate gilluminate requested review from jpople, lucanovera and speaker-ender and removed request for a team, jpople and lucanovera May 12, 2026 23:11
Copy link
Copy Markdown
Contributor

@speaker-ender speaker-ender left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and functions as intended. Code looks good as well

@gilluminate gilluminate enabled auto-merge May 15, 2026 15:17
@gilluminate gilluminate added this pull request to the merge queue May 15, 2026
Merged via the queue into main with commit f231e0f May 15, 2026
52 checks passed
@gilluminate gilluminate deleted the gill/ENG-3680/migrate-dnd-kit branch May 15, 2026 20:05
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.

2 participants