Skip to content

fix(CollectionControl): a11y drag handle and vertical axis lock#39863

Open
msyavuz wants to merge 1 commit intomasterfrom
react18-collection-dnd-a11y
Open

fix(CollectionControl): a11y drag handle and vertical axis lock#39863
msyavuz wants to merge 1 commit intomasterfrom
react18-collection-dnd-a11y

Conversation

@msyavuz
Copy link
Copy Markdown
Member

@msyavuz msyavuz commented May 4, 2026

SUMMARY

Follow-up to #38563.

dnd-kit's attributes (which include role="button", tabIndex={0}, aria-roledescription) were spread onto a <span> wrapping an <Icon role="img">, producing a button-role span containing an img-role child — a confusing a11y tree that isn't natively keyboard-activatable. The original (pre-React-18) implementation also used lockAxis="y"; the new dnd-kit version had no axis lock, so dragged items could drift horizontally.

  • Render the drag handle as <button type="button"> via setActivatorNodeRef so the activator (button) is distinct from the drop node and gets proper button semantics + native keyboard activation. Move aria-label="Drag to reorder" to the button; mark the icon aria-hidden.
  • Add restrictToVerticalAxis modifier to lock dragging to the y-axis (requires @dnd-kit/modifiers, peer-compatible with @dnd-kit/core 6.3+).
  • Add KeyboardSensor with sortableKeyboardCoordinates so the list can be reordered via keyboard.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — no visual change in the rest state. Drag now stays vertical and the handle is keyboard-activatable.

TESTING INSTRUCTIONS

  1. Open any chart with a CollectionControl (e.g. annotation layer list, custom controls list).
  2. Drag a row — confirm it moves only vertically (no horizontal drift).
  3. Tab to the drag handle — confirm it gets focus with a visible outline. Press Space to pick up, arrow keys to move, Space to drop.
  4. With a screen reader, confirm the handle is announced as "Drag to reorder, button" (not "img" or duplicate roles).

ADDITIONAL INFORMATION

  • Has associated issue: No
  • Required feature flags: None
  • Changes UI: Yes — drag handle is now a button, drag is axis-locked, keyboard reorder works
  • Includes DB Migration: No
  • Introduces new feature or API: No — existing component, additional dep @dnd-kit/modifiers
  • Removes existing feature or API: No

dnd-kit attributes (which include role="button", tabIndex, and
aria-roledescription) were spread onto a <span> wrapping an <Icon
role="img">, producing a button-role span containing an img-role child
— a confusing a11y tree that's not natively keyboard-activatable.

- Render the drag handle as <button type="button"> via setActivatorNodeRef
  so the activator (button) is distinct from the drop node, and gets
  proper button semantics + keyboard activation. Move the aria-label
  to the button and mark the icon aria-hidden.
- Add restrictToVerticalAxis modifier so dragged items can't drift
  horizontally (the original react-sortable-hoc implementation used
  lockAxis="y"). Adds @dnd-kit/modifiers (peer-compatible with
  @dnd-kit/core 6.3+).
- Add KeyboardSensor with sortableKeyboardCoordinates so the list can
  be reordered via keyboard.
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 4, 2026

Code Review Agent Run #609b51

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: ed1588a..ed1588a
    • superset-frontend/src/explore/components/controls/CollectionControl/index.tsx
  • Files skipped - 2
    • superset-frontend/package-lock.json - Reason: Filter setting
    • superset-frontend/package.json - Reason: Filter setting
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot Bot added change:frontend Requires changing the frontend dependencies:npm design:accessibility Related to accessibility standards explore:control Related to the controls panel of Explore labels May 4, 2026
@msyavuz msyavuz requested a review from rusackas May 4, 2026 16:54
@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 64.37%. Comparing base (41a22d7) to head (ed1588a).

Files with missing lines Patch % Lines
...re/components/controls/CollectionControl/index.tsx 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #39863   +/-   ##
=======================================
  Coverage   64.36%   64.37%           
=======================================
  Files        2569     2569           
  Lines      134745   134746    +1     
  Branches    31278    31278           
=======================================
+ Hits        86732    86738    +6     
+ Misses      46515    46510    -5     
  Partials     1498     1498           
Flag Coverage Δ
javascript 66.62% <50.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

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

Approving two small nits if you want to address them in this PR or follow-up:

(1) the hand-rolled with reset CSS could be a Button type="text" from @superset-ui/core/components and pick up theme focus styles for free

(2) a quick RTL test asserting aria-label="Drag to reorder" on the activator would close the Codecov gap on the new keyboard branch.

Copy link
Copy Markdown
Contributor

@alexandrusoare alexandrusoare left a comment

Choose a reason for hiding this comment

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

LGTM with just 1 nit

})}
>
<span {...attributes} {...listeners}>
<button
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we use the button from AntDesign here

@bito-code-review
Copy link
Copy Markdown
Contributor

No, AntDesign's Button component isn't used in this Superset project. The code uses a custom HTML button with CSS for drag handles, consistent with the project's UI patterns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend dependencies:npm design:accessibility Related to accessibility standards explore:control Related to the controls panel of Explore size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants