Repository navigation
Grid: preserve tile content semantics when dragging is disabled - #82511
chriskmnds wants to merge 3 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. To trigger a review, include ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Updated as activity occurs, without notifying anyone named here. Add the 🏷️ LabelsThis pull request needs exactly one label indicating its type, and has 0.
Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you. |
ee2e1e9 to
dd266ec
Compare
|
I rebased this on trunk ( Conflicts resolved in the first commit:
To pick it up: TestingNode 24.18.0.
For the |
adamwoodnz
left a comment
There was a problem hiding this comment.
Thanks @chriskmnds. This is a small, well-aimed fix: dropping the sortable attributes only when dragging is off removes the disabled role="button" ancestor and the dead tab stop, and keeps the enabled activator and resize handles as they were. The new sortable-semantics tests cover both layouts in read and pinned modes, with real links, buttons and a select inside the tile, which is the case that matters. The updated policy tests also check that the permitted controls stay enabled. I left one comment inline.
I reviewed the rebased branch from my earlier comment. The source change is the same as on this PR. I checked that no production code in grid or widget-dashboard depends on aria-roledescription="sortable" or aria-disabled on the activator, and that dnd-kit already returns listeners as undefined when disabled, so the activator div is inert in those modes.
Out of scope, for context: draggable tiles in edit mode still wrap their content in the role="button" activator (the nested-interactive issue noted on the EditMode stories, #81596).
| @@ -0,0 +1,138 @@ | |||
| import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; | |||
There was a problem hiding this comment.
Nit: this is a rendered test in jsdom, with a mocked ResizeObserver, fake timers and fireEvent key events. Trunk has been moving rendered Grid tests to Vitest Browser Mode (#80995, #82742). As a .browser.test.tsx, the Space/Escape pickup and focus checks would run against real events and layout, like keyboard-activation.browser.test.tsx. Not blocking.
|
Correction to my review: the jsdom test note is a blocker after the rebase, not a nit. Trunk's Vitest migration (#82742) added a conventions check that runs in Static Checks. On the rebased branch, Line 36 is the I pushed a fix to the same branch (https://github.com/adamwoodnz/gutenberg/tree/rebase/grid-inactive-sortable-semantics, now at On that commit, with Node 24.18.0:
I'm happy to raise a PR from my fork if you'd prefer I carry it from here, I don't mind either way 🙂 |
|
@chriskmnds I opened #84869 from the rebased branch so it can go up for review. It has your change, the rebase conflict fixes and the Browser Mode test from my comments above, and it credits you. If you prefer to reset this branch and continue here, tell me and I will close mine. |
The CHANGELOG check requires the Unreleased entry to cite the PR that carries it. The fix now lands through WordPress#84869, which supersedes WordPress#82511.
The CHANGELOG check requires the Unreleased entry to cite the PR that carries it. The fix now lands through WordPress#84869, which supersedes WordPress#82511.
The CHANGELOG check requires the Unreleased entry to cite the PR that carries it. The fix now lands through WordPress#84869, which supersedes WordPress#82511.
* Grid: preserve tile content semantics when dragging is disabled * WidgetDashboard: update pinned policy tests for inactive drag semantics * Grid: link changelog entry to pull request * Grid: Move sortable semantics test to Browser Mode Trunk's Vitest conventions check rejects jsdom tests that stub observer APIs, so the `ResizeObserver` stub made Static Checks fail after the rebase. In Browser Mode the test also uses real keyboard events and focus in place of `fireEvent` and fake timers. * Grid: Link changelog entry to #84869 The CHANGELOG check requires the Unreleased entry to cite the PR that carries it. The fix now lands through #84869, which supersedes #82511. * Grid: Move changelog entry to Unreleased Grid 0.10.0 was released while this PR was open. The rebase applied the entry cleanly inside the released 0.10.0 section, which would have listed the fix under a version that does not include it. * Grid: Say which tiles take keyboard focus in the README Tiles are no longer focusable in read mode or when pinned, so the keyboard steps apply only to draggable tiles in edit mode. * Grid: Add stories for interactive tile content and pinned items No story had native controls inside a tile or a pinned item, so the a11y addon could not catch a regression of the drag wrapper around them. The new stories open in read mode, where the addon runs, and the EditMode stories now pin one tile. * Grid: Say what the interactive content stories check The stories open in read mode, where no tile is draggable, so the "Draggable" labels misled readers. The descriptions now say that the a11y addon is what checks the stories, and that the pinned tile only matters in edit mode. --------- Co-authored-by: Christos <chriskmnds@gmail.com>
|
#84869 is merged and included your changes, you can close this. |
Thanks for following up @adamwoodnz. Good job. :-) |
What?
Closes #82507.
Remove inactive drag-control semantics from tile content in
DashboardGridandDashboardLanes, including pinned items.Why?
Read-mode and pinned tiles currently wrap their content in a focusable
role="button"witharia-disabled="true". This gives enabled links, buttons and form controls a disabled semantic ancestor and introduces an inactive drag control in the tab order.How?
Apply the sortable attributes only when dragging is enabled. Keep the existing listeners, refs, enabled activator and independent resize/action controls.
Update pinned-item and WidgetDashboard policy expectations, and add mounted tests for descendant semantics in both layouts, plus keyboard pickup, cancellation and focus for enabled drag controls and pinned resize handles. Move-denied widgets expose no drag activator while retaining permitted layout controls. Review should focus on the disabled wrapper semantics and preservation of permitted controls. Keyboard reorder completion in #82508 remains separate.
Testing Instructions
After rebasing onto trunk
980605ca93, all Grid and WidgetDashboard Vitest tests pass (252 tests), and changed-file lint passes. These focused checks ran on the available Node 24.12 environment with npm's engine gate bypassed because the host is below trunk's current Node 24.18 and npm 11.16 minimums; GitHub CI is validating the supported Node 24 and 26 matrix. Before the rebase, the previous head also passed the full production build and repository type check. The final Grid regression has four expected failures on unmodified wrappers and passes all eight cases with this change. These mounted JSDOM tests are complemented by fresh Chrome checks of both built layouts: native controls in read and pinned modes, enabled pickup/cancel with focus restoration, and pinned keyboard resizing. Full screen-reader qualification has not been performed.npm run test:unit:vitest -- packages/grid packages/widget-dashboard.editMode={ true }and adddraggable: falseto the layout item. Confirm that its content retains ordinary semantics and its resize handle remains available.DashboardLanes.Testing Instructions for Keyboard
editMode={ false }, Tab through the fixture. Focus should reach its native controls without stopping on an inactive drag wrapper. Activate Details with Enter, Refresh with Space, and change Metric with the arrow keys.draggable: falsein edit mode. Its permitted resize control should remain reachable.Screenshots or screencast
This changes accessibility semantics without a visual layout change.
Use of AI Tools
I used OpenAI Codex to investigate, implement and test this change.