Skip to content

Improve sortable list accessibility and remove drag-and-drop code#1813

Open
joshsadam wants to merge 11 commits intomainfrom
fix/sortable-lists-v1-a11y
Open

Improve sortable list accessibility and remove drag-and-drop code#1813
joshsadam wants to merge 11 commits intomainfrom
fix/sortable-lists-v1-a11y

Conversation

@joshsadam
Copy link
Copy Markdown
Contributor

@joshsadam joshsadam commented Apr 24, 2026

What does this PR do and why?

This updates sortable list interactions so keyboard and screen reader users can move, select, and reorder options with clearer focus feedback. It also removes old drag-and-drop grouping code that is no longer used, which makes the component simpler and less error-prone.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other pull requests.

image

How to set up and validate locally

  1. Start the app with bin/dev.
  2. Open http://localhost:3000/rails/view_components/sortable_lists_component_preview/two_lists and verify you can move focus with Tab, move between options with Arrow Up and Arrow Down, toggle selection with Space, add with Enter, remove with Delete, and reorder selected options with Alt+Arrow Up and Alt+Arrow Down.
  3. Confirm focus styling is clearly visible on the active option in both light and dark themes, and confirm it stays visible after moving options between lists.
  4. Open http://localhost:3000/rails/view_components/sortable_lists_component_preview/three_lists and verify list items are not draggable with the mouse, list behavior still works through buttons and keyboard, and no JavaScript errors appear in the browser console.
  5. Check an empty-list state by moving all options out of one list and confirm that list remains focusable while add/remove/up/down buttons are disabled until a valid selection exists.

PR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

@joshsadam joshsadam changed the title Fix/sortable lists v1 a11y Improve sortable list accessibility and remove drag-and-drop code Apr 24, 2026
@joshsadam joshsadam self-assigned this Apr 24, 2026
@joshsadam joshsadam force-pushed the fix/sortable-lists-v1-a11y branch from 732b46f to 7e271f3 Compare April 27, 2026 12:17
@joshsadam joshsadam marked this pull request as ready for review April 27, 2026 15:35
Copy link
Copy Markdown
Contributor

@ksierks ksierks left a comment

Choose a reason for hiding this comment

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

I was able to test the sortable lists through line list export, but the previews did not work for me.

@joshsadam
Copy link
Copy Markdown
Contributor Author

I was able to test the sortable lists through line list export, but the previews did not work for me.

Thanks for finding that, fixed in 580f169

@ChrisHuynh333
Copy link
Copy Markdown
Collaborator

Unless this changed, I believe we made the explicit decision to make the disabled buttons focusable since W3C's listbox components' disabled buttons are focusable/tabbable
https://www.w3.org/WAI/ARIA/apg/patterns/listbox/examples/listbox-rearrangeable/#ex2_label

@ericenns
Copy link
Copy Markdown
Member

Unless this changed, I believe we made the explicit decision to make the disabled buttons focusable since W3C's listbox components' disabled buttons are focusable/tabbable https://www.w3.org/WAI/ARIA/apg/patterns/listbox/examples/listbox-rearrangeable/#ex2_label

Yeah using aria-disabled is preferred instead of disabled as that way we can inform users that they need to select items from the list to be able to perform the action. That way they can discover the action whereas with disabled they are unable to discover the button with screen reader and know that they need to select data before they can perform the action.

@joshsadam joshsadam force-pushed the fix/sortable-lists-v1-a11y branch from 580f169 to c4ab10e Compare April 30, 2026 14:36
@joshsadam
Copy link
Copy Markdown
Contributor Author

Unless this changed, I believe we made the explicit decision to make the disabled buttons focusable since W3C's listbox components' disabled buttons are focusable/tabbable https://www.w3.org/WAI/ARIA/apg/patterns/listbox/examples/listbox-rearrangeable/#ex2_label

Yeah using aria-disabled is preferred instead of disabled as that way we can inform users that they need to select items from the list to be able to perform the action. That way they can discover the action whereas with disabled they are unable to discover the button with screen reader and know that they need to select data before they can perform the action.

Sounds good, sorry @ChrisHuynh333 and @ericenns updated in e3bca2d

ChrisHuynh333
ChrisHuynh333 previously approved these changes May 4, 2026
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.

4 participants