Repository navigation
feat(accessibility): give the library's own controls fixed identifiers - #85
Conversation
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]>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
romchornyi
left a comment
There was a problem hiding this comment.
✅ 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 baredelete.leftsymbol, 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.AddressFieldViewalready takes afieldIdentifier(#78).- Two stacked
BottomSheets both answer tonavigationbar-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
- The override test does not go through the public method —
ControlIdentifierTests.swift#L55— it calls the internalaccessibilityIdentifier(_:), sobutton(accessibilityIdentifier:action:)dropping its argument would stay green. - An empty override removes the fixed identifier —
NavigationBar.swift#L196—""is applied as is. Treat it asnil, asAddressFieldViewdoes withisEnabled:, or say so in the doc comment. - 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. - The new overload adds little over
.accessibilityIdentifier(_:)on the returned view —NavigationBar.swift#L188— the docs say both work. If it stays, wiring it intoBottomSheetwould 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]>
|
Review addressed in 0b129a4:
Checked in a throwaway XCUITest app: |
romchornyi
left a comment
There was a problem hiding this comment.
✅ 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
-
NumericKeyboardViewnames delete and the decimal separator (numerickeyboard-delete,numerickeyboard-decimal), tested foren_USandde_DE; the digits keep their labels. -
SearchBar's field carriessearchbar-field. - Stacked
BottomSheets are tracked in #86. -
testTheButtonOverloadCarriesTheHostsIdentifiergoes 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
BottomSheetis #86.
The overload test reads SwiftUI's dump() output, which may change between SDKs; the test says so.
🤖 Reviewed with Claude Code
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
NavigationBarElementbuttons apart, such as aBottomSheetheader's close over a screen with its own.What was done?
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;nilor 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.NavigationBarCircleButtonandNavigationBarCircleMenuset no identifier of their own, so a host's.accessibilityIdentifier(_:)on them already names the control (as the docs say).VotePillstays out: many pills share a screen, so it needs a host-set identifier, not a fixed one. TwoBottomSheets stacked both keepnavigationbar-closeon 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 getsenteramount-swap: without an identifier of its own it took the secondary chevron's, andswapamount-secondary-currencymatched twice.docs/, the override innavigation-and-containers.md, and for twoAddressFieldViews 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 (niland""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 inen_USandde_DEbut no digit. It failed to build before the change.addressfield-clearandsearchbar-cancelonce their field has focus),screen-closereplacednavigationbar-closeon the overridden button, andnilkeptnavigationbar-back. It also showed that an outer.accessibilityIdentifier(_:)(on the button, or on a plainHStackaround it) replaces the fixed one, and that a field wrapped in.accessibilityElement(children: .contain)with its own identifier scopesaddressfield-scanto one match. No committed test reads the rendered hierarchy: the package's unit tests cannot reach SwiftUI's accessibility tree.xcodebuildfor a generic iOS device,conventions.sh.Before / After
Only accessibility identifiers are added; nothing is drawn differently.
Breaking Changes
None: a new overload, and identifiers on controls that had none.
Checklist:
🤖 Generated with Claude Code