Skip to content

Give repeater row controls accessible names and keyboard support - #126

Closed
Contributolo wants to merge 1 commit into
inline0:mainfrom
Contributolo:fix/repeater-row-control-names
Closed

Contributolo wants to merge 1 commit into
inline0:mainfrom
Contributolo:fix/repeater-row-control-names

Conversation

@Contributolo

Copy link
Copy Markdown
Collaborator

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):

  • No accessible name. No aria-label, text or title, so screen readers announce all three as just "button" (WCAG 4.1.2 Name, Role, Value).
  • Space does not activate them. Only Enter is handled. Space reaches the keyboard sensor of the row's drag handle (@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, ...), not div role="button". The APG button pattern expects Enter and Space to activate (WCAG 2.1.1 Keyboard).
  • The collapse control does not expose whether the row is expanded.

Fix

  • The controls are Button components from @wordpress/components (as used for the field label actions and the expanded editor trigger) with a translatable label that includes the row number: "Collapse row 2" / "Expand row 2", "Duplicate row 2", "Remove row 2".
  • The collapse control sets aria-expanded (APG disclosure pattern).
  • Native buttons handle Enter and Space, and the drag sensor ignores them, so Space no longer starts a drag. Arrow-key reordering on the focused row is unchanged.
  • The label also shows as a tooltip on hover and keyboard focus, like other icon buttons in the editor.
  • Size, dashed border, hover color and class names stay the same. The one visible difference: icons use the core foreground color #1e1e1e instead of pure black, and focus shows the core focus ring.
  • New strings go through __() in the blockstudio domain with translator comments; npm run i18n updated the catalog, and de_DE and de_DE_formal have translations.

Tests

  • New tests/e2e/types/repeater/controls.ts: checks the names per row with getByRole('button', { name }), collapse/expand with Enter and Space (including aria-expanded and 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 > button instead of > div > [role="button"].
  • Against the previous bundle, the new test fails on the first name assertion. On the previous bundle, Space on a focused control lifted the row into a drag.
  • Against this branch: tests/e2e/types/repeater/ (all files) and tests/e2e/types/icon.ts pass, 116 tests.
  • npm run check passes (eslint, tsc, docs, schemas, neutrality, i18n:check, client tests).

Not changed

The row itself gets role="button" and tabindex="0" from provided.dragHandleProps once a repeater has more than one row, so the row's form fields and these controls are nested inside an element with role button. 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.

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.
@dnnsjsk

dnnsjsk commented Oct 17, 2026 •

Copy link
Copy Markdown
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.

@dnnsjsk dnnsjsk closed this Oct 17, 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.

2 participants