Skip to content

[iOS][MacCatalyst] Fix accessibility hierarchy for non-UIElement semantic containers - #36702

Open
SuthiYuvaraj wants to merge 63 commits into
dotnet:net11from
SuthiYuvaraj:fix-accessibility-approach
Open

SuthiYuvaraj wants to merge 63 commits into
dotnet:net11from
SuthiYuvaraj:fix-accessibility-approach

Conversation

@SuthiYuvaraj

Copy link
Copy Markdown
Contributor

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-UIControl container (in this case ContentView) had semantic text assigned, the container was automatically marked as an accessibility element.

As a result:

  • VoiceOver treated the entire container as a single accessibility element.
  • Child elements were no longer exposed individually.
  • Users could not navigate or interact with child content independently.

RootCause

IsAccessibilityElement was being set to true for 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

  • Android
  • Windows
  • iOS
  • Mac

Output Screenshot

Before Issue Fix After Issue Fix
ContentViewBefore.mov
ContentViewAfter.mov

@github-actions

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jul 21, 2026
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Jul 23, 2026
@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-gate-failed AI could not verify tests catch the bug s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) labels Jul 24, 2026
MauiBot

This comment was marked as outdated.

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Expert Review — 2 findings

See inline comments for details.

Comment thread src/Core/src/Platform/iOS/MauiView.cs Resolved
@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Jul 24, 2026
@SuthiYuvaraj SuthiYuvaraj changed the title [WIP] [iOS][MacCatalyst] Fix accessibility hierarchy for non-UIElement semantic containers [iOS][MacCatalyst] Fix accessibility hierarchy for non-UIElement semantic containers Jul 27, 2026
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Jul 27, 2026
@MauiBot MauiBot added s/agent-fix-win AI found a better alternative fix than the PR and removed s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates labels Jul 27, 2026
github-actions Bot and others added 4 commits December 1, 2026 07:01
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>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

github-actions Bot and others added 7 commits December 1, 2026 08:40
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>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

github-actions Bot and others added 7 commits December 1, 2026 10:16
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>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[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++)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@github-actions

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

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 /review autopilot to run again.

Why

The fix round stopped before publishing changes: dotnet test --project src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj -p:TargetFrameworks=net11.0 --filter-class "*SemanticPropertyUnitTests" reproduced CA1860 in VisualDiagnosticsOverlay.cs:222 on both the PR head and merge base 79db9cb05b, before any tests ran. #41083 fixes that error on net11, where the Core build passed; retry after the PR branch includes that fix.

[Run](https://github.com/dotnet/maui/actions/runs/47190819936).

This branch was previously deployed

1 inactive (outdated) deployment
copilot-pat-pool — 7ab5c370 Deployed Nov 24, 2026 by kubaflo via conclusion #3289
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) s/autopilot-needs-maintainer-decision MAUI Autopilot stopped: a maintainer needs to decide how to continue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent Accessibility Behavior Across Platforms in MAUI

5 participants