Repository navigation
Give repeater row controls accessible names and keyboard support - #126
Closed
Contributolo wants to merge 1 commit into
Closed
Contributolo wants to merge 1 commit into
Contributolo wants to merge 1 commit into
Conversation
The collapse, duplicate and remove controls of a repeater row were rendered as `div role="button"` with only an icon inside. They had no accessible name, so screen readers announced each of them as "button". They reacted to Enter only: Space, which activates a button, reached the keyboard sensor of the row's drag handle first and lifted the row into a keyboard drag, because that sensor only skips native interactive elements. The controls are now `Button` components from @wordpress/components with a translatable label that includes the row number: "Collapse row 2", "Duplicate row 2" and "Remove row 2". The collapse control switches to "Expand row 2" and exposes its state with aria-expanded. Native buttons handle Enter and Space and are ignored by the drag sensor, so Space no longer starts a drag. The label is also shown as a tooltip. Size, dashed border and hover color stay as before; the class names are unchanged. References: WCAG 2.2 success criteria 4.1.2 Name, Role, Value and 2.1.1 Keyboard; WAI-ARIA APG button pattern (Enter and Space activate) and disclosure pattern (aria-expanded). A new E2E test covers the names and operation with Enter and Space. The existing remove test selects the controls as buttons instead of by role="button". German translations are added for de_DE and de_DE_formal.
Contributor
|
Included in Blockstudio 7.7.4. Accessible repeater controls and native keyboard activation have shipped, with browser coverage for names, expanded state and focus behavior. Your changes were incorporated into the consolidated release branch with integration tests and release adjustments, so I am closing this PR as shipped rather than merging the original branch again. Full CI (14/14) and Distribution (5/5) passed on release commit e1d38df. Thank you for the contribution. |
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.
Problem
Each repeater row in the block inspector has three icon controls: collapse, duplicate and remove (
.blockstudio-repeater__minimize,__duplicate,__remove). They are rendered as<div role="button" tabindex="0">with only an SVG inside (src/blocks/components/fields/components/repeater.tsx, the control map):aria-label, text or title, so screen readers announce all three as just "button" (WCAG 4.1.2 Name, Role, Value).@hello-pangea/dnd) first and lifts the whole row into a keyboard drag ("You have lifted an item in position 1"), because the sensor only skips native interactive elements (input,button, ...), notdiv role="button". The APG button pattern expects Enter and Space to activate (WCAG 2.1.1 Keyboard).Fix
Buttoncomponents from@wordpress/components(as used for the field label actions and the expanded editor trigger) with a translatablelabelthat includes the row number: "Collapse row 2" / "Expand row 2", "Duplicate row 2", "Remove row 2".aria-expanded(APG disclosure pattern).#1e1e1einstead of pure black, and focus shows the core focus ring.__()in theblockstudiodomain with translator comments;npm run i18nupdated the catalog, and de_DE and de_DE_formal have translations.Tests
tests/e2e/types/repeater/controls.ts: checks the names per row withgetByRole('button', { name }), collapse/expand with Enter and Space (includingaria-expandedand focus staying on the control), duplicate with Enter, and remove with Space and Enter after the confirmation.tests/e2e/types/repeater/repeater.ts(remove): the control count now selects> div > buttoninstead of> div > [role="button"].tests/e2e/types/repeater/(all files) andtests/e2e/types/icon.tspass, 116 tests.npm run checkpasses (eslint, tsc, docs, schemas, neutrality,i18n:check, client tests).Not changed
The row itself gets
role="button"andtabindex="0"fromprovided.dragHandlePropsonce a repeater has more than one row, so the row's form fields and these controls are nested inside an element with rolebutton. Changing that would need a separate drag handle and would change how rows are dragged and reordered, so it is left for a separate discussion.