Repository navigation
[iOS][MacCatalyst] Fix accessibility hierarchy for non-UIElement semantic containers - #36702
SuthiYuvaraj wants to merge 63 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
MauiBot
left a comment
There was a problem hiding this comment.
Expert Review — 2 findings
See inline comments for details.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Expert Review — 8 findings · ⚠️ 2 breaking changes
Reviewed commit 246d31c.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
See inline comments for details.
| && !defaults.IsAccessibilityElement && !defaults.IsHeading && settings?.HasAccessibleGesture != true | ||
| && view.PresentedContent is not null && HasAccessibleSubview(platformView, 0); | ||
|
|
||
| var isElement = explicitRole ?? !groupChildren; |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - An existing iOS/MacCatalyst ContentView with Description="Balance: ten dollars", a child Label displaying "$10", no gesture/heading, and unset IsInAccessibleTree previously exposed one VoiceOver stop announcing the curated description. This branch instead exposes the child and removes the parent's announcement. ShouldGroupAccessibilityChildren groups traversal but supplies no accessible owner for the non-element parent's Description/Hint; parent-only instructions are lost too. GroupedContentKeepsItsOwnSemanticText checks stored strings, not accessible exposure. IsInAccessibleTree=true restores the summary at the cost of independent child traversal, but the frozen PR narrative neither discloses this working-summary change nor documents that escape hatch. Preserve an accessible representation of parent semantics and disclose the tradeoff. If targeting servicing, retain the old default behind an opt-in; for main, document the opt-out and breaking change.
There was a problem hiding this comment.
MAUI Autopilot · round 6
❌ Not changed. Grouping keeps child actions reachable but can remove the announcement of the parent summary or hint. Deciding whether that tradeoff is acceptable by default in servicing, or requires an opt-in, is a maintainer decision; this round preserves the PR’s approach.
| foreach (var additionalTap in additionalTaps) | ||
| additionalTap.SendTapped(view, GetPosition); | ||
| } | ||
| return true; |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - Direct content activation bypasses existing native extensions. Consider an enabled, described Border with a primary single-tap MAUI recognizer plus a handler-installed UITapGestureRecognizer on the same native view, configured for simultaneous single-tap recognition. On iOS where UIKit activation already worked, the previous simulated-touch path ran both recognizers; this callback dispatches only MAUI GestureRecognizers and returns true, so MauiView.AccessibilityActivate skips UIKit and the native callback no longer runs. IsInAccessibleTree=true does not restore native dispatch, while false removes the accessible action. The added activation tests cover MAUI recognizers and positions, not native callbacks. Provide a compatibility activation-path option and disclose this callback-frequency change: preserve native dispatch by default behind an opt-in if servicing, or provide an opt-out and breaking-change callout if main.
There was a problem hiding this comment.
MAUI Autopilot · round 6
❌ Not changed. The new activation path can bypass an app-installed native activation callback. Defining callback precedence or introducing an opt-in would change the PR’s activation contract, so this stays open for a maintainer decision.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Expert Review — 9 findings · ⚠️ 2 breaking changes
Reviewed commit b6a88dc.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
Source assessment incomplete (17/18 dimensions); finding count is partial.
See inline comments for details.
| var settings = view as IContentViewAccessibility; | ||
| bool? explicitRole = settings?.IsInAccessibleTree; | ||
| bool groupChildren = explicitRole != true && !defaults.HasSemanticHeading | ||
| && !defaults.IsAccessibilityElement && !defaults.IsHeading && settings?.HasAccessibleGesture != true |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - An existing iOS/MacCatalyst ContentView with Description="Balance: ten dollars", a child Label displaying "$10", no gesture/heading, and unset IsInAccessibleTree previously exposed one VoiceOver stop announcing the curated description. This branch instead exposes the child and removes the parent's announcement. ShouldGroupAccessibilityChildren groups traversal but supplies no accessible owner for the non-element parent's Description/Hint; parent-only instructions are lost too. GroupedContentKeepsItsOwnSemanticText checks stored strings, not accessible exposure. IsInAccessibleTree=true restores the summary at the cost of independent child traversal, but the frozen PR narrative neither discloses this working-summary change nor documents that escape hatch. Preserve an accessible representation of parent semantics and disclose the tradeoff. With the target branch unspecified, retain the old default behind an opt-in if servicing; for main, document the opt-out and breaking change.
There was a problem hiding this comment.
MAUI Autopilot · round 7
❌ Not changed. On the net11 servicing target, preserving a separate parent announcement or changing default grouping requires a maintainer decision. Explicit IsInAccessibleTree=true restores the summary stop but gives up independent child traversal.
| { | ||
| foreach (var additionalTap in additionalTaps) | ||
| additionalTap.SendTapped(view, GetPosition); | ||
| } |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - Direct content activation bypasses existing native extensions. Consider an enabled, described Border with a primary single-tap MAUI recognizer plus a handler-installed UITapGestureRecognizer on the same native view, configured for simultaneous single-tap recognition. On iOS where UIKit activation already worked, the previous simulated-touch path ran both recognizers; this callback dispatches only MAUI GestureRecognizers and returns true, so MauiView.AccessibilityActivate skips UIKit and the native callback no longer runs. IsInAccessibleTree=true does not restore native dispatch, while false removes the accessible action. The added activation tests cover MAUI recognizers and positions, not native callbacks. Provide a compatibility activation-path option and disclose this callback-frequency change. With the target branch unspecified, preserve native dispatch by default behind an opt-in if servicing, or provide an opt-out and breaking-change callout if main.
There was a problem hiding this comment.
MAUI Autopilot · round 7
❌ Not changed. Restoring UIKit dispatch would change the PR’s explicit activation design, and IsInAccessibleTree=true does not restore native callbacks. The servicing default and migration guidance need a maintainer decision.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Expert Review — 3 findings · ⚠️ 2 breaking changes
Reviewed commit ea92b54.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
See inline comments for details.
| && !defaults.IsAccessibilityElement && !defaults.IsHeading && settings?.HasAccessibleGesture != true | ||
| && view.PresentedContent is not null && HasAccessibleSubview(platformView, 0); | ||
|
|
||
| var isElement = explicitRole ?? !groupChildren; |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - An existing iOS/MacCatalyst ContentView with Description="Balance: ten dollars", a child Label displaying "$10", no gesture/heading, and unset IsInAccessibleTree previously supplied one VoiceOver stop announcing the curated description. This branch instead exposes the child and removes the parent's announcement. ShouldGroupAccessibilityChildren groups traversal but supplies no accessible owner for the non-element parent's Description/Hint; parent-only instructions are lost too. GroupedContentKeepsItsOwnSemanticText checks stored strings, not accessible exposure. IsInAccessibleTree=true restores the summary at the cost of independent child traversal, but the frozen PR narrative neither discloses this tradeoff nor documents that escape hatch. Preserve an accessible representation of parent semantics and document the compatibility choice. For servicing, retain the old default behind an opt-in; for main, document the opt-out and breaking change.
There was a problem hiding this comment.
MAUI Autopilot · round 8
❌ Not changed. Grouping preserves independent child traversal but does not give the parent its own VoiceOver stop; IsInAccessibleTree=true keeps the parent stop at the cost of child traversal. Changing that default or adding a separate parent stop is a servicing compatibility decision for the maintainer, and the tradeoff still needs to be disclosed.
| foreach (var additionalTap in additionalTaps) | ||
| additionalTap.SendTapped(view, GetPosition); | ||
| } | ||
| return true; |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - Direct content activation bypasses existing native gesture extensions. Consider an enabled, described Border with a primary single-tap MAUI recognizer plus a handler-installed UITapGestureRecognizer on the same native view, configured for simultaneous single-tap recognition. On iOS where UIKit activation already worked, the previous simulated-touch path ran both recognizers; this callback now dispatches only MAUI GestureRecognizers and returns true, so MauiView.AccessibilityActivate skips UIKit and the native callback no longer runs. The multi-tap and position repairs do not preserve native callbacks. IsInAccessibleTree=true does not restore native dispatch, while false removes the accessible action. Provide a compatibility activation-path option and disclose this callback-frequency change: preserve native dispatch by default behind an opt-in for servicing, or provide an opt-out and breaking-change callout for main. The activation tests cover MAUI recognizers and positions, not native callbacks.
There was a problem hiding this comment.
MAUI Autopilot · round 8
❌ Not changed. Successful direct activation skips UIKit fallback. Restoring native dispatch unconditionally could double-invoke a MAUI action, while disabling the direct path by default would change this PR’s activation fix. A servicing default or opt-in, plus disclosure for apps with custom native recognizers, needs a maintainer decision.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Expert Review — 5 findings · ⚠️ 2 breaking changes
Reviewed commit d7a9194.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
See inline comments for details.
| && !defaults.IsAccessibilityElement && !defaults.IsHeading && settings?.HasAccessibleGesture != true | ||
| && view.PresentedContent is not null && HasAccessibleSubview(platformView, 0); | ||
|
|
||
| var isElement = explicitRole ?? !groupChildren; |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - An existing iOS/MacCatalyst ContentView with Description="Balance: ten dollars", a child Label displaying "$10", no gesture/heading, and unset IsInAccessibleTree previously supplied one VoiceOver stop announcing the curated description. This branch instead exposes the child and removes the parent's announcement. ShouldGroupAccessibilityChildren groups traversal but supplies no accessible owner for the non-element parent's Description/Hint; parent-only instructions are lost too. IsInAccessibleTree=true restores the summary at the cost of independent child traversal, but the frozen PR narrative neither discloses this tradeoff nor documents that escape hatch. With the target branch unspecified, make the compatibility choice explicit: retain the old default behind an opt-in for servicing, or document the opt-out and breaking change for main.
[major] Logic and Correctness Verification - Preserve an accessible representation of the parent semantics alongside independently reachable children. GroupedContentKeepsItsOwnSemanticText checks stored native strings, not their exposure to VoiceOver, so it does not protect the parent's announcement.
| foreach (var additionalTap in additionalTaps) | ||
| additionalTap.SendTapped(view, GetPosition); | ||
| } | ||
| return true; |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - Direct content activation bypasses existing native gesture extensions. Consider an enabled, described Border with a primary single-tap MAUI recognizer plus a handler-installed UITapGestureRecognizer on the same native view, configured for simultaneous single-tap recognition. On iOS where UIKit activation already worked, the previous simulated-touch path ran both recognizers; this callback now dispatches only MAUI GestureRecognizers and returns true, so MauiView.AccessibilityActivate skips UIKit and the native callback no longer runs. IsInAccessibleTree=true does not restore native dispatch, while false removes the accessible action. The added activation tests cover MAUI recognizers and positions, not native callbacks. Provide a compatibility activation-path option and disclose this callback-frequency change: preserve native dispatch by default behind an opt-in for servicing, or provide an opt-out and breaking-change callout for main; the target branch is not supplied.
| if (platformView.ValueForKey(s_subviewsKey) is NSArray subviews) | ||
| { | ||
| var count = subviews.Count; | ||
| for (nuint i = 0; i < count; i++) |
There was a problem hiding this comment.
[major] Performance-Critical Path Optimization - Filtering sibling items still causes quadratic native-tree work. Attach a described ContentView containing a Grid/BindableLayout of N accessible Buttons, then hide those items through their bound IsVisible properties in child order. Each item's visibility-propagation batch disposes before the next notification and remaps the same ContentView. This loop restarts at zero and reads the growing hidden prefix, adding O(N-squared) synchronous NSArray item accesses and native Hidden reads on the UI thread, even with VoiceOver off. Lazy KVC avoids eager marshaling but not these repeated scans. The population/range and single-parent visibility tests do not cover independent sibling notifications. Cache and correctly invalidate subtree participation, or coalesce refreshes across this filtering operation.
| _tempElement = null; | ||
|
|
||
| if (((IElementHandler)this).PlatformView is PlatformView platformView) | ||
| Microsoft.Maui.Platform.SemanticExtensions.RefreshAncestorContentRoles(platformView); |
There was a problem hiding this comment.
[moderate] Backward Compatibility and Migration - Initial compatibility content mapping does not refresh its own final role. Append to FrameRenderer.Mapper's Content mapping to set the native child's AccessibilityElementsHidden=true, then attach a Frame with Button content and Description already set. ProcessAutoPackage attaches the initially accessible Button before UpdateProperties; inherited Semantics runs before Content and makes the FrameView a grouped non-element. The Content append then hides the Button, but this finalization refreshes only ancestors of the FrameView, leaving neither a reachable child nor the parent's semantic focus stop. Subsequent Content updates and modern handlers refresh the host itself. Refresh the renderer's own content role after the complete initial mapping pass; ReplacingCompatibilityContentRestoresParentFocus sets Description only after attachment and misses this ordering.
| return false; | ||
|
|
||
| // Even an empty explicit array replaces UIKit's subview traversal. | ||
| if (GetExplicitAccessibilityElements(platformView) is { } elements) |
There was a problem hiding this comment.
[moderate] Accessibility - The scan misses the count/index form of UIAccessibilityContainer. A custom-handler UIView can expose accessible UIAccessibilityElement children through accessibilityElementCount and accessibilityElementAtIndex: while leaving accessibilityElements null and having no UIView subviews, as with individually accessible regions of a drawn chart. This method checks only the array and subviews, returns false for that valid native tree, and makes a described enclosing Border/ContentView a leaf, hiding those children. Conversely, an overridden count of zero can suppress an internal UILabel that this fallback incorrectly counts, removing the parent's fallback focus stop despite no reachable child. Honor the count/index container contract before inferring participation from subviews. ContentRoleRecognizesExplicitNativeAccessibilityElements covers only the array form.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
MAUI Autopilot — Stopped@kubaflo ❌ The build already fails at this PR's merge base, not because of this PR. Apply the base fix (see Why for details), update the PR branch to include it, then comment WhyThe fix round stopped before publishing changes: |
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Issue Description
When a non-
UIControlcontainer (in this caseContentView) had semantic text assigned, the container was automatically marked as an accessibility element.As a result:
RootCause
IsAccessibilityElementwas being set totruefor non-interactive containers whenever semantic text was present, without considering accessible child elements.This caused VoiceOver to stop traversing the container's descendants and instead expose only the container itself.
Description of Change
SemanticsExtensions:Updated the semantics handling to preserve child accessibility elements when semantic properties are applied to a non-UIElement container.MauiView: Modified the accessibility container behavior so the parent semantics do not prevent VoiceOver from exposing and reading the child accessible elements.Issues Fixed
Fixes #33612
Tested the behaviour in the following platforms
Output Screenshot
ContentViewBefore.mov
ContentViewAfter.mov