Skip to content

feat(menu-item): label the toggle and add a row action - #63

Merged
ross-dash merged 1 commit into
masterfrom
feat/menuitem-toggle-a11y
Nov 13, 2026
Merged

ross-dash merged 1 commit into
masterfrom
feat/menuitem-toggle-a11y

Conversation

@ross-dash

@ross-dash ross-dash commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Issue being fixed or feature implemented

Fixes #56. A MenuItem toggle accessory was exposed to assistive technologies as an unlabelled Toggle, and a row that both opens an explainer and carries a switch could not keep the two apart: wrapping the row in a Button merged the switch into it. dashwallet-ios works around this in Settings (dashpay/dashwallet-ios#1282: the whole row is the switch, the explainer is a "Learn more" custom action that Voice Control does not list).

What was done?

  • .toggle accessory: the SwitchView gets .accessibilityLabel(Text(title)), so it reads as the row's setting.
  • New MenuItem(…, action:) initializer and action property. With an action, the icon and text are one Button (plain style, disabled with the row) and the accessory stays a separate element. Without one the row behaves as before.
  • The existing initializer is unchanged; the new one is an overload, so no caller changes.
  • Preview "Accessory: toggle + row action"; docs/lists-and-rows.md documents the action and the toggle label.

How Has This Been Tested?

  • swift build, .github/scripts/conventions.sh.
  • Not yet checked with VoiceOver on a device. The app-side follow-up (dropping the Settings workaround) will verify it there.

Before / After

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

Rows without action render exactly as before; with action the layout is the same HStack, only wrapped in a plain button. The toggle label is not drawn.

Breaking Changes

None. The previous initializer keeps its signature.

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
    • Menu rows can now trigger an action when their icon or text is selected, while keeping the accessory separate.
    • Toggle accessories are announced with the row title for improved accessibility.
  • Documentation
    • Added guidance and an example for combining row actions with toggle accessories.

A toggle accessory was exposed as an unlabelled Toggle, and a row that both
opens an explainer and carries a switch could not keep them apart: wrapping
the row in a Button merged the switch into it. The switch is now labelled
with the row title, and MenuItem(…, action:) makes the icon and text one
button while the accessory stays its own element. The existing initializer
is unchanged.

Fixes #56

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

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

MenuItem adds an optional action for its icon and text while keeping the accessory separate. Toggle accessories now use the row title as their accessibility label. Documentation and a preview show a row action alongside a toggle.

Changes: MenuItem actions and toggle accessibility

Layer / File(s) Summary
Row action and toggle accessibility
Sources/DashUIKit/Components/MenuItem.swift, docs/lists-and-rows.md
MenuItem adds an action initializer and renders the icon and text as a button when an action exists. The button is disabled when isEnabled is false, and the accessory remains separate. The toggle uses the row title as its accessibility label. The preview and documentation show the action with a toggle.

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

Change: Feature · Severity of issue fixed: Medium

Suggested reviewers: romchornyi

Merge Risk: Minimal · up to 20fb6

This change adds a separate row action to MenuItem and labels toggles with the row title. Existing rows without an action are unchanged. No concrete merge-blocking risk was found. VoiceOver behavior on a device still needs a manual check.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat(menu-item): label the toggle and add a row action" matches the changeset. The PR labels the toggle accessory with the row title for VoiceOver and adds a public MenuItem initializer wit…
Linked Issues check Passed Issue #56 has two coding requirements. (1) The toggle accessory is labelled with the row title. In Sources/DashUIKit/Components/MenuItem.swift, the .toggle case adds `.accessibilityLabel(Text(title)…
Out of Scope Changes check Passed All changes map to issue #56. The accessibility label and the action initializer implement the two requirements. The preview and docs/lists-and-rows.md describe the new API and label. The change set c…
Full details: Title check

Explanation

The title "feat(menu-item): label the toggle and add a row action" matches the changeset. The PR labels the toggle accessory with the row title for VoiceOver and adds a public MenuItem initializer with an action parameter that makes the icon and text a plain button. Both changes appear in the title, and the title is short and specific. It uses a conventional-commit style prefix, which is acceptable.

Full details: Linked Issues check

Explanation

Issue #56 has two coding requirements. (1) The toggle accessory is labelled with the row title. In Sources/DashUIKit/Components/MenuItem.swift, the .toggle case adds .accessibilityLabel(Text(title)) to SwitchView. (2) The row's own action stays a separate, reachable element, or an explicit API exists for it. The new MenuItem(…, action:) initializer and public var action wrap the icon and text in a plain Button. The trailing accessory stays outside that button, so the switch is a separate element. The diff adds a preview for this layout and updates docs/lists-and-rows.md. The existing initializer is unchanged. No automated test was added. The issue does not request one, so this does not fail the check. Runtime VoiceOver and Voice Control behaviour was not verified on a device. The source evidence supports the requirements as stated.

Full details: Out of Scope Changes check

Explanation

All changes map to issue #56. The accessibility label and the action initializer implement the two requirements. The preview and docs/lists-and-rows.md describe the new API and label. The change set contains no unrelated edits in the reviewed diff for MenuItem.swift. Rows without an action keep the original layout path.

Finishing Touches

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 41ff490 and 20fb607.

Files selected for processing: 2

  • Sources/DashUIKit/Components/MenuItem.swift
  • docs/lists-and-rows.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.

@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.

Verdict: approve

No blockers or majors. Reviewed at 20fb607.

Level Verdict
1 · Idea ✅ Fixes #56: an unlabelled switch, and a row that cannot keep its explainer and its switch apart
2 · Architecture ✅ An additive overload. The old initializer and every caller are unchanged
3 · Completeness ✅ Docs and a preview are included. The app-side follow-up (dropping the dashwallet-ios#1282 workaround) is named
4 · Code ✅ Clean

Checked

  • Without action the body is the same leading/central/Spacer sequence as before, so existing rows render identically. CI "Snapshot tests" and "Before / After" pass with the old references.
  • With action the button is disabled with the row (.disabled(!isEnabled)), and .contentShape(Rectangle()) keeps the whole text area tappable, including the spacer.
  • MenuItem(title:) without an action still resolves to the old initializer, because action has no default in the overload. A trailing closure picks the new one.
  • SwitchView gets .accessibilityLabel(Text(title)). That fits the toggle-row convention: the switch is the row's setting.

Recommendations (non-blocking)

  1. Snapshot of the new variant. MenuItemSnapshotTests has no row with action. One case (toggle + action, enabled and disabled) would pin the "same layout, only wrapped in a plain button" claim and the disabled styling inside a disabled Button.
  2. Two elements with the same leading name. With action, the button reads "Advanced mode, Tap to learn more" and the switch reads "Advanced mode". For Voice Control both answer to "tap Advanced mode", so it falls back to numbered disambiguation. It is still separable, which is the point of #56. Consider an .accessibilityHint on the button, or let the host pass a distinct label for the explainer.
  3. Device check. "Not yet checked with VoiceOver on a device" is fair for a library change. Please carry it into the app follow-up's test notes so it is not lost.

🤖 Reviewed with Claude Code

@ross-dash
ross-dash merged commit b1653e4 into master Nov 13, 2026
12 checks passed
@ross-dash
ross-dash deleted the feat/menuitem-toggle-a11y branch November 13, 2026 12:40
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.

MenuItem: label the toggle accessory with the row title and keep the row's own action reachable

3 participants