From e1a1af02264e2c94d20024b531fee94ee95a64a2 Mon Sep 17 00:00:00 2001 From: SHAIK KHADEER BASHA <120262074+KhadeerBasha1232@users.noreply.github.com> Date: Fri, 4 Dec 2026 13:53:15 +0530 Subject: [PATCH] Label each variable anchor and offset for screen readers (#2395) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- AGENTS.md | 5 +++++ CHANGELOG.md | 1 + e2e/layers-list.spec.ts | 8 ++++++++ src/components/InputVariableAnchorOffsetCollection.tsx | 7 ++++--- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 637642b6..ee8ac479 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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. diff --git a/CHANGELOG.md b/CHANGELOG.md index 44c7ef6b..6df361ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/e2e/layers-list.spec.ts b/e2e/layers-list.spec.ts index 21d77f69..6ff3528e 100644 --- a/e2e/layers-list.spec.ts +++ b/e2e/layers-list.spec.ts @@ -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"); diff --git a/src/components/InputVariableAnchorOffsetCollection.tsx b/src/components/InputVariableAnchorOffsetCollection.tsx index c79068bf..e792fc94 100644 --- a/src/components/InputVariableAnchorOffsetCollection.tsx +++ b/src/components/InputVariableAnchorOffsetCollection.tsx @@ -58,6 +58,7 @@ class InputVariableAnchorOffsetCollectionInternal extends React.Component
this.deleteValue(i)} {...i18nProps} /> @@ -68,17 +69,17 @@ class InputVariableAnchorOffsetCollectionInternal extends React.Component this.changeAnchor(i, v as string)} - aria-label={label} + aria-label={t("{{label}} row {{row}} anchor", { label, row })} /> this.changeOffset(i, 0, v)} - aria-label={label} + aria-label={t("{{label}} row {{row}} X offset", { label, row })} /> this.changeOffset(i, 1, v)} - aria-label={label} + aria-label={t("{{label}} row {{row}} Y offset", { label, row })} />