Repository navigation
Fix the modal's close button: VoiceOver name on iOS, Material placement on Android - #214
Open
wojt-janowski wants to merge 2 commits into
Open
wojt-janowski wants to merge 2 commits into
wojt-janowski wants to merge 2 commits into
Conversation
The modal applies its a11y-label to the whole stack, and SwiftUI gives a
plain container's label to each of its children, so VoiceOver read the
close button as the modal's label ("Account details") instead of "Close".
The stack is now an accessibility element that contains its children, so
the label names the modal and the close button keeps its own.
Amp-Thread-ID: https://ampcode.com/threads/T-01a1dca0-8660-73ca-b541-c07f690843ea
Co-authored-by: Wojt Janowski <wojt@clinically.com.au>
Material 3 full-screen dialogs put the close icon at the start of the top bar, where a screen's navigation icon goes. The modal drew it at the end, which is where the dialog's confirming action belongs. Start follows the layout direction, so in right-to-left layouts it sits on the right. Amp-Thread-ID: https://ampcode.com/threads/T-01a1dca0-8660-73ca-b541-c07f690843ea Co-authored-by: Wojt Janowski <wojt@clinically.com.au>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two fixes to the modal's close button, one per commit, so either can be taken on its own.
Problem
A11yLabelModifierputs the modal'sa11y-labelon the wholeVStack. SwiftUI gives a plain container'saccessibilityLabelto each child, so witha11y-label="Account details"the close button was announced as "Account details" instead of "Close".Fix
NativeUIModalRenderer.swift: when there's a label, the stack becomes.accessibilityElement(children: .contain)before the label is applied. The label then names the modal and the close button keeps "Close". Without a label nothing changes.ModalRenderer.kt: the close row usesArrangement.Startinstead ofArrangement.End. Start follows the layout direction, so it's on the right in RTL. iOS keeps its trailing close button.The Android status-bar icon fix this used to need is already in 0.10.0 (#194).
Test plan
tests/ModalRendererTest.phpgains a case for each change, in the file's existing source-matching style. Each fails without its commit. Full suite: 504 passed; Pint clean.axe describe-ui). Before: the close button's label was "Account details". After:Group 'Account details'containingButton 'Close', followed by the modal's text..isModal) is unchanged in code but wasn't re-checked with VoiceOver running.