-
Notifications
You must be signed in to change notification settings - Fork 469
Popup: Android screen reader accessibility #2959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Removed the `TapGestureRecognizer` from the `PopupPage` constructor to simplify tap handling logic. Updated `PopupPageLayout` to enhance accessibility by excluding the overlay `Grid` and `PopupBorder` from the accessibility tree, ensuring only relevant popup content is accessible to assistive technologies.
Refactored the `VerticalStackLayout.Resources` section in `ButtonPopup.xaml` for better readability and consistency. Added a `Loaded` event handler (`Label_Loaded`) to the `Label` with the `Title` style to set semantic focus on load, enhancing accessibility. Implemented the `Label_Loaded` method in `ButtonPopup.xaml.cs` to handle this functionality.
Removed comments explaining the accessibility setup for the overlay Grid and PopupBorder. No functional changes were made to the accessibility behavior, as the relevant `AutomationProperties.SetIsInAccessibleTree` calls remain unchanged. The comments were likely removed for clarity or to reduce redundancy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes Android screen reader accessibility for the Popup component by ensuring that non-interactive container elements are excluded from the accessibility tree, allowing screen readers to properly focus on interactive and content elements within the popup.
Key Changes:
- Set
IsInAccessibleTreeto false for popup container elements (PopupPageLayout and PopupBorder) to improve screen reader navigation - Added semantic focus to the first label in the ButtonPopup sample to demonstrate proper accessibility behavior
- Applied formatting improvements to the ButtonPopup.xaml sample
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/CommunityToolkit.Maui/Views/Popup/PopupPage.shared.cs | Excludes popup container elements from accessibility tree to fix Android screen reader focus issues |
| samples/CommunityToolkit.Maui.Sample/Views/Popups/ButtonPopup.xaml.cs | Adds event handler to set semantic focus on the title label when loaded |
| samples/CommunityToolkit.Maui.Sample/Views/Popups/ButtonPopup.xaml | Wires up Loaded event and applies formatting improvements (tabs to spaces) |
Update Label_Loaded method with nullability and logic The `Label_Loaded` method in `ButtonPopup.xaml.cs` was updated to accept a nullable `sender` parameter by changing its signature to `void Label_Loaded(object? sender, EventArgs e)`. Additionally, the method implementation was added to check if the `sender` is of type `Label`. If so, it casts the `sender` to a `Label` and calls the `SetSemanticFocus` method on it.
|
This is the website is use to validate accessibility behaviour, as you can see this PR matches what is expected - https://www.magentaa11y.com/#/native-criteria/notifications/modal?tab=4 |
Description of Change
Fix Android screen reader accessibility
As you can see from the before video, the non-interactive elements (labels) arnt focusable to the screenreader. And the popup view itself is.
android-before.mp4
android-after.mp4
I've tested iOS and it is unchanged from before, and behaves the same as the after video on Android.
Linked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information