Skip to content

fix: hide the toast icon from VoiceOver - #39

Merged
romchornyi merged 4 commits into
masterfrom
fix/toast-icon-voiceover
Oct 31, 2026
Merged

romchornyi merged 4 commits into
masterfrom
fix/toast-icon-voiceover

Conversation

@romchornyi

@romchornyi romchornyi commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Issue being fixed or feature implemented

VoiceOver reads the toast's icon by its asset name before the message: "toast-warning, image", "toast-no-wifi, image" and so on. This was measured in the accessibility tree on the iOS simulator.

Stacked on #36, which changed ToastStyle to draw DashIcon.Toast cases. Once #36 merges, this PR's base becomes master.

What was done?

  • The icon is hidden from VoiceOver, so VoiceOver reads only the message. The style is not spoken by default: DashUIKit ships no translations, and dashwallet-ios already names the style in several messages ("Copied", "No internet connection"), so a built-in prefix would be read in English or read twice.
  • New Toast.init(style:message:accessibilityLabel:onDismiss:). A host that wants the style spoken passes a Text that VoiceOver reads instead of the message, for example "Error, payment failed". It is a Text, like the labels of NavigationBarCircleButton and NavigationBarCircleMenu, so the host localizes it. The existing init is unchanged.
  • Docs: docs/feedback.md describes what VoiceOver reads and how to localize the label. The README.md row lists .noInternet and the label.
  • Preview: a toast with a label, and a typo fixed ("Sgome").

The other components that draw .custom icons through Image(dash:) have the same problem. That is tracked in #38.

How Has This Been Tested?

  • swift build (macOS), the iOS Release device build, and xcodebuild test on the iOS 27 simulator: 18 tests, 0 failures.
  • conventions.sh passes, and api-check.sh against refactor: route asset names through DashIcon #36's head reports no breaking changes.
  • VoiceOver: the accessibility tree of each style was dumped on the simulator with a test harness, before and after. A unit test can't read it without a private framework.
Before After
.warning, "Message" toast-warning (image), Message, Close (button) Message, Close (button)
.noInternet, "Message" toast-no-wifi (image), Message, Close Message, Close
.loading, "Message" Message, Close Message, Close
.error, "Message", label "Error, message" — Error, message, Close

The other styles match .warning.

Before / After

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

Only what VoiceOver reads changes; nothing is drawn differently. See the table in "How Has This Been Tested?".

Breaking Changes

None. The existing init keeps its signature, and the API check is clean. Hosts whose UI tests find a toast by its icon's accessibility label will no longer find it.

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

Summary by CodeRabbit

  • New Features
    • Toast messages now support a custom VoiceOver label. Without one, VoiceOver reads the toast message.
    • VoiceOver skips the leading icon, and the dismiss button remains a separate focus stop.
  • Documentation
    • Added guidance on toast accessibility labels and announcements.

romchornyi and others added 3 commits October 27, 2026 10:59
The toast, nav bar and converter badge drew their icons from string names
that conventions.sh could not see; they now use DashIcon cases.
NavigationBarElement keeps its public raw values and draws through
DashIcon.NavigationBar; a test keeps the two in step.

conventions.sh flags a package-bundle lookup whose name is not one
literal (outside the Icon_DashUI / Color+DashUI resolvers), a computed
name in the host bundle, an empty name and a computed dashAsset() name.
A unit test checks that every DashIcon case resolves in the package
bundle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y are

Follow-up to the review of this PR:
- each call's literal names are read once, so a ternary in the host
  bundle or a repeated missing name is reported once;
- a .custom(…) that passes a bundle is a lookup wherever it sits, and a
  computed name in .main / nil / .none is reported;
- an empty name also gets its bundle checked;
- negative needles ("!text") are checked in pass cases too;
- CLAUDE.md, docs/foundation.md and the script header say what the scan
  does and does not follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
VoiceOver read the icon by its asset name ("toast-warning, image") before
the message. The icon is now hidden, and a new init takes an
accessibilityLabel that VoiceOver reads instead of the message, for hosts
that want the style spoken.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 4adba34 and cb29552.

Files selected for processing: 3
  • README.md
  • Sources/DashUIKit/Components/Toast.swift
  • docs/feedback.md

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

Toast now accepts an optional custom VoiceOver label. The default label uses the message, and the leading icon is hidden from accessibility. The preview and documentation include the custom label behavior, and the README lists noInternet as a supported toast type.

Changes: Toast accessibility

Layer / File(s) Summary
Add and apply the Toast accessibility label
Sources/DashUIKit/Components/Toast.swift, docs/feedback.md, README.md
Toast stores and applies a custom accessibility label, and hides its leading icon from accessibility. The existing initializer defaults the label to the message. The preview and documentation describe custom labels and host responsibilities. The README adds noInternet to the Toast catalog.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • dashpay/DashUIKit#38 — The issue identifies the Toast icon accessibility behavior addressed by this change; its other listed components are not changed.

Possibly related PRs

  • dashpay/DashUIKit#36 — It changes the Toast icon implementation and adds the .noInternet style, which this PR documents and updates for accessibility.

Suggested reviewers: jeanpierreroma

Merge Risk: Minimal · up to cb295

No actionable merge-blocking issue is established for the toast accessibility changes. The PR appears mergeable subject to normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the primary change: hiding the toast icon from VoiceOver. It is directly related to the pull request changes.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files. (2 skipped: 2 unsupported.)

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • 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-pitcrew

romchornyi-pitcrew commented Oct 27, 2026 •

Copy link
Copy Markdown

✅ Review posted for commit cb29552 · triage: normal · approve · took 0 min

@romchornyi-pitcrew romchornyi-pitcrew left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ no blockers · no majors · 6 non-blocking recommendations — reviewed at 54f6fd6dc6

Level Verdict
1 · Idea 🟡 interim fix Real defect (VoiceOver reads "toast-warning, image"). The root cause is shared: Image(dash:) / DashIcon.*.image build .custom icons with Image(name, bundle:), so the asset name becomes the label. This PR fixes Toast only; #38 tracks the shared fix
2 · Architecture ✅ right layer The component owns its accessibility. The opt-in Text label matches NavigationBarCircleButton / NavigationBarCircleMenu
3 · Completeness 🟡 gaps partly tracked #38 exists but leaves out several components that draw icons the same way (list below)
4 · Code ✅ clean Text(message) with a String is verbatim, so the default label is unchanged. The hidden wrapper also covers the .loading spinner. The only host (dashwallet-ios) keeps the old init

Components to add to #38. These draw icons through Image(dash:) or DashIcon.*.image, with no accessibility modifier at this head:

  • DashButton (icon inside the button label);
  • SearchBar;
  • AddressFieldView;
  • DashAmount;
  • DashBalanceView;
  • SwapAmountView;
  • ConverterCard beyond ConverterArrowBadge;
  • SuccessIllustration / ErrorIllustration.
6 non-blocking recommendations
  1. VoiceOver loses the only style cue for existing calls —
    leadingIcon
    .frame(width: 24, height: 24)
    .accessibilityHidden(true)
    — every host call uses the old init. dashwallet-ios maps .failed(let reason) to .error with the raw reason as the message (https://github.com/dashpay/dashwallet-ios/blob/develop/DashWallet/Sources/UI/Payments/InternalTransfer/Confirm/InternalTransferToastModifier.swift#L93-L123), so VoiceOver now reads only the reason. "Another transfer is still in progress" (.warning) sounds the same as a .success toast. "toast-error, image" was a poor cue, but it was a cue. The PR's argument, that messages already name the style, holds for "Copied" and "No internet connection" but not for these. A companion dashwallet-ios change that passes accessibilityLabel: for .error / .warning would close it. (verified in dashwallet-ios develop)
  2. The shared fix in one place —
    var image: Image { Image(dash: source) }
    — Image(decorative: name, bundle:) for library-bundled .custom icons, or a decorative flag on DashIconSource, would fix Toast and every component in #38 at once, and keep new components from repeating it. Worth naming in #38 as the preferred direction, since this PR adds a Toast-only .accessibilityHidden.
  3. The docs example and the host's string tooling —
    VoiceOver reads only the message; the icon is hidden from it. When the style matters to a
    listener and the message does not say it, pass an `accessibilityLabel:` to read instead of
    the message. It is a `Text`: a literal `Text("…")` is looked up in the app's main bundle,
    `Text("…", bundle: .module)` in a package's, and a `String` variable is read as is. VoiceOver
    reads it when focus lands on the message (the dismiss button is a separate stop); announcing
    the toast as it appears is the host's job, like its presentation. The label replaces the
    message's, for UI tests too, so build it from the same localized message, and add the new
    key to the host's strings like any other:
    ```swift
    Toast(style: .error, message: paymentFailed,
    accessibilityLabel: Text("Error, \(paymentFailed)")) // key "Error, %@"
    ```
    — the example localizes with a SwiftUI literal key (Text("Error, \(x)") → "Error, %@"). dashwallet-ios runs BartyCrouch with [update.code] additive = false, which extracts NSLocalizedString calls, not Text("…") keys. A key added by hand can then be removed on the next update and ship in English everywhere. Showing Text(String(format: NSLocalizedString("Error, %@", comment: …), message)) as well would fit the only consumer. (the additive = false setting is verified; how the tool treats Text literals is not)
  4. Announce on appear —
    .accessibilityLabel(accessibilityLabel)
    — the label is read only when focus lands on the message. Toasts in dashwallet-ios last 3–3.5 s with no announcement, so a VoiceOver user rarely hears them. The docs give this job to the host. Posting AccessibilityNotification.Announcement once per message inside Toast would make the label reach users. (not verified at runtime)
  5. Label and message can drift —
    /// host that wants the style spoken too ("Error, payment failed"). It is a
    /// `Text`, so the host localizes it as it would a `Button` title. It replaces
    /// the message's label, so pass a new one with every new message. The icon
    /// itself is never read.
    public init(
    style: ToastStyle,
    message: String,
    accessibilityLabel: Text,
    onDismiss: (() -> Void)? = nil
    ) {
    self.style = style
    self.message = message
    self.accessibilityLabel = accessibilityLabel
    — the label replaces the message for VoiceOver and UI tests, and only the doc comment asks the host to rebuild it with every message. A narrower spokenStyle: Text? that Toast combines with Text(message) would rule out a stale label.
  6. Default path adds a redundant override —
    self.init(style: style, message: message, accessibilityLabel: Text(message), onDismiss: onDismiss)
    — the old init passes Text(message) only so it can be applied as the label of an identical Text. A Text? stored property, applied only when non-nil, keeps SwiftUI's own label on the default path and makes the override visibly opt-in.
Review details

Tier: normal (public component API plus accessibility behaviour), stacked on #36. Levels 1–3 inline, including #38's body. Level 4 used the general lane (/code-review high) and the UI/accessibility specialist lane (default-label parity, spinner, element structure, the localization claims in the docs, host call sites, API shape). The verifier checked:

  • the host toast mapping and .bartycrouch.toml in dashwallet-ios;
  • #38's component list against the call sites.

Dropped: an empty-label edge case (Text("")), which is the host's input, and the README row wording.

At the time of review, Conventions, Lint CI config and Validate PR title were still pending. The builds, unit tests, API check and Before / After screenshots were green.

🤖 Reviewed with Claude Code

Base automatically changed from refactor/asset-names-dashicon to master October 30, 2026 11:31
…eover

# Conflicts:
#	.github/scripts/conventions.sh
#	.github/scripts/tests/conventions-test.sh
#	docs/feedback.md

@romchornyi-pitcrew romchornyi-pitcrew left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ no blockers · no majors · 3 non-blocking recommendations — reviewed at cb29552799 (re-review)

Level Verdict
1 · Idea 🟡 interim fix Unchanged since the last review: Toast is fixed in place, and the shared cause in Image(dash:) is tracked in #38
2 · Architecture ✅ right layer Unchanged: the component owns its accessibility; the opt-in Text label matches the navigation bar buttons
3 · Completeness 🟡 untracked gaps #38 still lists none of the components named in the last review (below)
4 · Code ✅ clean The new head only merges master (#36, #37). The PR's own diff against master is identical to the one reviewed at 54f6fd6, and CI is green on it

Since the last review

  • Rebased onto master by a merge commit after #36 and #37 landed; the conflicts were in the CI scripts, which now match master exactly. Toast.swift, README.md and docs/feedback.md carry the same change as before.

Untracked gaps (still). These draw icons through Image(dash:) or DashIcon.*.image with no accessibility modifier and are not in #38: DashButton, SearchBar, AddressFieldView, DashAmount, DashBalanceView, SwapAmountView, ConverterCard beyond ConverterArrowBadge, SuccessIllustration / ErrorIllustration. Please add them to #38, or say there why they are out of scope.

3 non-blocking recommendations
  1. The PR description is out of date — it still says the PR is stacked on #36 and that api-check.sh ran against #36's head. The base is master now; the Public API check on this head is the current evidence.
  2. Recommendations 1–6 of the last review are still open, with no reply. None blocks. The two worth an answer before merge: the companion dashwallet-ios change that passes accessibilityLabel: for .error / .warning (VoiceOver no longer hears any style cue there —
    leadingIcon
    .frame(width: 24, height: 24)
    .accessibilityHidden(true)
    ), and the shared decorative fix at
    var image: Image { Image(dash: source) }
    as #38's preferred direction.
  3. The docs example and BartyCrouch —
    VoiceOver reads only the message; the icon is hidden from it. When the style matters to a
    listener and the message does not say it, pass an `accessibilityLabel:` to read instead of
    the message. It is a `Text`: a literal `Text("…")` is looked up in the app's main bundle,
    `Text("…", bundle: .module)` in a package's, and a `String` variable is read as is. VoiceOver
    reads it when focus lands on the message (the dismiss button is a separate stop); announcing
    the toast as it appears is the host's job, like its presentation. The label replaces the
    message's, for UI tests too, so build it from the same localized message, and add the new
    key to the host's strings like any other:
    ```swift
    Toast(style: .error, message: paymentFailed,
    accessibilityLabel: Text("Error, \(paymentFailed)")) // key "Error, %@"
    — the Text("Error, \(x)") literal key may not survive additive = false in the host; unchanged from the last review. (not verified)
Review details

Re-review of the head after the merge of master. The PR's own diff (Sources, README.md, docs) was compared line by line with the diff reviewed at 54f6fd6: identical. Levels 1–3 re-checked inline, including #38's current body. Level 4: Toast.swift read at this head; the merge touches no PR-owned line. All 8 CI checks pass at this head.

🤖 Reviewed with Claude Code

@romchornyi
romchornyi merged commit 402db65 into master Oct 31, 2026
11 checks passed
@romchornyi
romchornyi deleted the fix/toast-icon-voiceover branch October 31, 2026 12:59
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