Label each variable anchor and offset for screen readers (#2395)

Follow-up to #2393. In each `text-variable-anchor-offset` row, the
anchor dropdown and both offset fields shared the property name as their
accessible label, so a screen reader announced the same name for every
control in every row. Each control's label now adds its row and what it
edits to the property label, for example "… row 2 X offset".

The labels go through `t()` like the other strings in the component. I
didn't add them to `src/locales/*`; they fall back to English until
translated.

There's no visual change; only the `aria-label` attributes differ.

**Performance:** none. Only the label strings change.

## Launch Checklist

 - [x] Briefly describe the changes in this PR.
 - [x] Link to related issues: follow-up to #2393.
- [x] Include before/after visuals or gifs if this PR includes visual
changes: no visual change.
- [x] Write tests for all new functionality: an e2e test in
`layers-list.spec.ts` that adds a second row and checks the anchor, X
offset and Y offset labels. It fails on `main`.
 - [x] Add an entry to `CHANGELOG.md` under the `## main` section.

Tested locally: `npm run lint` clean, `npx tsc --noEmit` clean, `npx
vitest run` (57 passed) and `npx playwright test
e2e/layers-list.spec.ts` (48 passed). The new test fails when I run it
against `main`. I didn't run the full e2e suite locally (it times out on
Windows with several workers); it passes in CI on this PR.

Assisted-By: Claude Opus 5.5 (Claude Code). It helped write the change,
the test and this description. I've reviewed and tested the change and
can answer questions about it.
This commit is contained in:
SHAIK KHADEER BASHA authored and GitHub committed 2026-12-04 10:23:15 +02:00
1 parent bb1cd631a2
commit e1a1af0226
4 files changed
+18 -3

No files matched your search

+5
View File
@@ -42,6 +42,11 @@ Run the unit tests with Vitest:
npm run test-unit
```
## Accessibility
- Every input, select and button needs an accessible name. `InputString`, `InputNumber`, `InputSelect` and `InputButton` accept an `aria-label`.
- When a control repeats, as in the rows of an array or collection field, give each copy its own label that names the row and what it edits (for example `… row 2 X offset`), and pass it through `t()`. Controls that share one label can't be told apart with a screen reader.
## Pull Requests
- Pull requests should update `CHANGELOG.md` with a short description of the change.
+1
View File
@@ -14,6 +14,7 @@
- _...Add new stuff here..._
### 🐞 Bug fixes
- Add distinct screen reader labels for the anchor, X offset, and Y offset in each variable anchor offset row.
- Open `icon-padding` expressions in the expression editor so they can be viewed and edited.
- Fix `icon-padding` showing four inputs and only saving once all four were filled; it now uses the same add/remove list as other number arrays, up to four values
- Make small sprites easier to recognize in the sprite picker with fixed-size previews and high-resolution sprite assets
+8
View File
@@ -260,6 +260,14 @@ describe("layers list", () => {
});
});
test("should identify each anchor and offset by row and axis", async () => {
await when.addValueToPropertyArray("spec-field:text-variable-anchor-offset", "8");
await then(get.element("[data-wd-key='spec-field:text-variable-anchor-offset'] select[aria-label$='row 1 anchor']")).shouldBeVisible();
await then(get.element("[data-wd-key='spec-field:text-variable-anchor-offset'] input[aria-label$='row 2 X offset']")).shouldHaveValue("0");
await then(get.element("[data-wd-key='spec-field:text-variable-anchor-offset'] input[aria-label$='row 2 Y offset']")).shouldHaveValue("8");
});
test("should remove an anchor row", async () => {
// the row's delete button shares the function stop's class
await when.deleteFunctionStop("text-variable-anchor-offset");
@@ -58,6 +58,7 @@ class InputVariableAnchorOffsetCollectionInternal extends React.Component<InputV
for (let i = 0; i < this.values.length / 2; i++) {
const anchor = this.values[i * 2] as string;
const [x, y] = this.values[i * 2 + 1] as [number, number];
const row = i + 1;
rows.push(<div key={i} className="maputnik-array-block">
<div className="maputnik-array-block-action">
<DeleteValueInputButton onClick={() => this.deleteValue(i)} {...i18nProps} />
@@ -68,17 +69,17 @@ class InputVariableAnchorOffsetCollectionInternal extends React.Component<InputV
options={anchorOptions}
value={anchor}
onChange={(v) => this.changeAnchor(i, v as string)}
aria-label={label}
aria-label={t("{{label}} row {{row}} anchor", { label, row })}
/>
<InputNumber
value={x}
onChange={(v) => this.changeOffset(i, 0, v)}
aria-label={label}
aria-label={t("{{label}} row {{row}} X offset", { label, row })}
/>
<InputNumber
value={y}
onChange={(v) => this.changeOffset(i, 1, v)}
aria-label={label}
aria-label={t("{{label}} row {{row}} Y offset", { label, row })}
/>
</div>
</div>