Skip to content

feat(accessibility): give the library's own controls fixed identifiers - #85

Merged
romchornyi merged 2 commits into
dashpay:masterfrom
romchornyi-pitcrew:fix/a11y-identifiers
Dec 3, 2026
Merged

romchornyi merged 2 commits into
dashpay:masterfrom
romchornyi-pitcrew:fix/a11y-identifiers

Conversation

@romchornyi-pitcrew

@romchornyi-pitcrew romchornyi-pitcrew commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

Closes #49.

UI tests could find these controls only by their English label, which stops matching once the package is localized. A host also had no way to tell two NavigationBarElement buttons apart, such as a BottomSheet header's close over a screen with its own.

What was done?

  • Fixed accessibility identifiers, the same in every language, on the controls DashUIKit names itself. They are listed in one internal enum, ControlIdentifier:
    • toast-close, systemmessage-close;
    • searchbar-field, searchbar-clear, searchbar-cancel;
    • addressfield-scan, addressfield-clear, addressfield-paste;
    • filterbar-filter;
    • enteramount-max, enteramount-swap (the dual-swap amounts, one element), swapamount-currency, swapamount-secondary-currency;
    • convertercard-swap;
    • numerickeyboard-delete, numerickeyboard-decimal (the digits keep their labels).
  • NavigationBarElement.button(accessibilityIdentifier:action:): the same button with the host's identifier; nil or an empty string keeps the fixed one. button(action:) is unchanged. An .accessibilityIdentifier(_:) on the returned view replaces the fixed identifier too, as on any ancestor that is not a container; the parameter states it at the call.
  • Not changed: NavigationBarCircleButton and NavigationBarCircleMenu set no identifier of their own, so a host's .accessibilityIdentifier(_:) on them already names the control (as the docs say). VotePill stays out: many pills share a screen, so it needs a host-set identifier, not a fixed one. Two BottomSheets stacked both keep navigationbar-close on their header close: the sheet takes no identifier of its own, tracked in BottomSheet: tell the header buttons of two stacked sheets apart in UI tests #86.
  • DualSwapAmountView's combined swap element gets enteramount-swap: without an identifier of its own it took the secondary chevron's, and swapamount-secondary-currency matched twice.
  • Docs: the identifiers in each component's doc comment and next to it in docs/, the override in navigation-and-containers.md, and for two AddressFieldViews on one screen, a container per field to scope the query.

How Has This Been Tested?

  • ControlIdentifierTests: the documented values, no identifier used twice across the library, the override (nil and "" keep the element's identifier), the public overload passing the host's identifier to the view it returns (dropping it fails the test), and the keyboard naming delete and the decimal separator in en_US and de_DE but no digit. It failed to build before the change.
  • A throwaway app with an XCUITest target hosted every control and queried each identifier: each matched one button (addressfield-clear and searchbar-cancel once their field has focus), screen-close replaced navigationbar-close on the overridden button, and nil kept navigationbar-back. It also showed that an outer .accessibilityIdentifier(_:) (on the button, or on a plain HStack around it) replaces the fixed one, and that a field wrapped in .accessibilityElement(children: .contain) with its own identifier scopes addressfield-scan to one match. No committed test reads the rendered hierarchy: the package's unit tests cannot reach SwiftUI's accessibility tree.
  • Whole suite: iPhone 17 simulator, iOS 26.5. xcodebuild for a generic iOS device, conventions.sh.

Before / After

  • No visual change (refactor, tests, docs). Say why in "What was done?".

Only accessibility identifiers are added; nothing is drawn differently.

Breaking Changes

None: a new overload, and identifiers on controls that had none.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

🤖 Generated with Claude Code

UI tests could find these controls only by their English label. Each now
has an accessibility identifier that does not change with the language,
listed in ControlIdentifier: the close buttons of Toast and
SystemMessageView, SearchBar's clear and Cancel, AddressFieldView's scan,
clear and Paste, FilterBar's filter button, EnterAmountView's Max and
dual-swap element, SwapAmountView's currency chevrons and ConverterCard's
swap badge.

NavigationBarElement.button(accessibilityIdentifier:action:) gives a bar
button the host's identifier, for a screen with two of the same element;
nil keeps the fixed one.

Closes dashpay#49.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@romchornyi romchornyi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No blockers, no major · 3 untracked gaps · 4 non-blocking recommendations — reviewed at 5a501f890a

Level Verdict
1 · Idea ✅ valid #49: UI tests found these controls only by English labels.
2 · Architecture ✅ right layer Each component sets its own identifier from one internal ControlIdentifier, with a uniqueness test.
3 · Completeness 🟡 untracked gaps Below.
4 · Code ✅ clean CI green.

Level 3 gaps

  • NumericKeyboardView's keys have no identifier — NumericKeyboardView.swift#L233 — the delete key is a bare delete.left symbol, labelled by the system in the user's language, and the decimal key is "." or "," by locale. That is the case this PR fixes elsewhere (numerickeyboard-delete, numerickeyboard-decimal).
  • SearchBar's text field has no identifier — SearchBar.swift#L112 — a test can find it only by the localized "Search" prompt. AddressFieldView already takes a fieldIdentifier (#78).
  • Two stacked BottomSheets both answer to navigationbar-close — BottomSheet.swift#L155 — the description says so; the new parameter does not reach the sheet's header. Worth an issue.
4 non-blocking recommendations
  1. The override test does not go through the public method — ControlIdentifierTests.swift#L55 — it calls the internal accessibilityIdentifier(_:), so button(accessibilityIdentifier:action:) dropping its argument would stay green.
  2. An empty override removes the fixed identifier — NavigationBar.swift#L196 — "" is applied as is. Treat it as nil, as AddressFieldView does with isEnabled:, or say so in the doc comment.
  3. The identifiers are only in docs/ — ControlIdentifier.swift#L19 — the comment says each control's docs list its identifier, but the components' doc comments do not, and the enum is internal, so Quick Help shows nothing.
  4. The new overload adds little over .accessibilityIdentifier(_:) on the returned view — NavigationBar.swift#L188 — the docs say both work. If it stays, wiring it into BottomSheet would give it the case it was added for.
Review details

Levels 1–3 inline, including a sweep of the library's own labelled controls for ones without an identifier; level 4 /code-review high.

🤖 Reviewed with Claude Code

Review on dashpay#85:
- NumericKeyboardView's delete key and decimal separator, whose labels
  change with the language, carry numerickeyboard-delete and
  numerickeyboard-decimal; SearchBar's text field carries searchbar-field.
- An empty override keeps a bar button's fixed identifier, as nil does.
- A test goes through button(accessibilityIdentifier:action:) itself.
- Each component's doc comment lists its identifiers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@romchornyi-pitcrew

Copy link
Copy Markdown
Contributor Author

Review addressed in 0b129a4:

  1. testTheButtonOverloadCarriesTheHostsIdentifier goes through button(accessibilityIdentifier:action:): making it pass nil instead of its argument fails the test.
  2. An empty string keeps the fixed identifier, as nil does; the doc comment and docs say so.
  3. Each component's doc comment now lists its identifiers.
  4. The overload stays: it is the override Language-independent accessibility identifiers for the remaining controls, and a host override #49 asked for. Wiring it into BottomSheet is BottomSheet: tell the header buttons of two stacked sheets apart in UI tests #86.

Checked in a throwaway XCUITest app: numerickeyboard-delete, numerickeyboard-decimal (de_DE) and searchbar-field each match one element. Whole suite and conventions.sh pass.

@romchornyi romchornyi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No blockers, no major · all gaps and recommendations closed — re-reviewed at 0b129a418f

Level Verdict
1 · Idea ✅ valid Unchanged.
2 · Architecture ✅ right layer Unchanged.
3 · Completeness ✅ gaps tracked Stacked BottomSheets are #86.
4 · Code ✅ clean The diff since 5a501f890a is the new identifiers, doc comments and tests; CI green.

Closed since the last review

  • NumericKeyboardView names delete and the decimal separator (numerickeyboard-delete, numerickeyboard-decimal), tested for en_US and de_DE; the digits keep their labels.
  • SearchBar's field carries searchbar-field.
  • Stacked BottomSheets are tracked in #86.
  • testTheButtonOverloadCarriesTheHostsIdentifier goes through the public overload.
  • An empty override keeps the fixed identifier, tested and documented.
  • Each component's doc comment lists its identifiers.
  • The overload stays as #49's override; wiring it into BottomSheet is #86.

The overload test reads SwiftUI's dump() output, which may change between SDKs; the test says so.

🤖 Reviewed with Claude Code

@romchornyi
romchornyi merged commit 71d08c6 into dashpay:master Dec 3, 2026
12 checks passed
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.

Language-independent accessibility identifiers for the remaining controls, and a host override

2 participants