[Windows][net11] Make Layout AutomationPeer public + opt-in for screen reader tree - #35909
[Windows][net11] Make Layout AutomationPeer public + opt-in for screen reader tree#35909kubaflo wants to merge 1 commit into
Conversation
…et11) Net11.0 version of dotnet#35597 (follow-up to dotnet#35562). Targets net11.0 so the new public API can land, and actions the deferred ".NET11.0" TODO by making MauiLayoutAutomationPeer public instead of internal. - MauiLayoutAutomationPeer is now `public` (class + constructor); the "TODO: Make this class public in .NET11.0" is resolved. - Added the corresponding net-windows PublicAPI.Unshipped.txt entries (type, constructor, and the six protected overrides), matching the existing MauiButtonAutomationPeer pattern. - LayoutPanel.OnCreateAutomationPeer + the AutomationId/screen-reader opt-in behavior are unchanged from dotnet#35597. Co-authored-by: Redth <jondick@gmail.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 35909Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 35909" |
Fleet code review — PR #35909Reviewed head SHA: Independent assessmentThis Windows-only change adds a Findings by severity❌ ErrorsNone found in the product implementation or PublicAPI surface.
|
…n reader tree (#35597) <!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change Follow-up to #35562, now targeting `net11.0`. #35562 added `MauiLayoutAutomationPeer` so `AutomationId` set on a `Layout` would be visible to UI Automation clients (Appium / WinAppDriver, etc.), fixing #4715. As a side effect, every `LayoutPanel` was reported as `IsControlElement = true`, which put every `Grid` / `StackLayout` / `VerticalStackLayout` / `ContentView` into the UIA **Control view** that screen readers (Narrator, NVDA) walk -- noisy as soon as anyone adds an `AutomationId` for UI testing. This PR makes the layout peer **opt-in** for the screen-reader tree, and -- because it targets `net11.0` -- actions the deferred `.NET11.0` TODO by making `MauiLayoutAutomationPeer` **public** (class + constructor) and adding the matching `net-windows` PublicAPI entries (type, constructor, and the six protected overrides). This PR supersedes #35909 (which was the net11.0 staging of these changes). **Behavior after this PR:** | Set on a Layout / ContentView | UIA raw view (UI tests) | UIA Control view (screen readers) | UIA Content view | |---|---|---|---| | Nothing | excluded | excluded | excluded | | `AutomationId="..."` only | **included** | **included** as `Custom` with no localized control type | excluded | | `AutomationProperties.IsInAccessibleTree="True"` | included | **included** | **included** | | `SemanticProperties.Description="..."` (or `Hint`) | included | **included** | excluded | So: - Pure test hook: `AutomationId` alone keeps Windows UI tests working. It enters the Control view for Appium / WinAppDriver discoverability, but reports `Custom` with an empty localized control type instead of a grouping `Pane`. - Accessibility landmark: `AutomationProperties.IsInAccessibleTree="True"` opts the panel into the accessibility tree. Screen readers see it. - Accessibility content: `SemanticProperties.Description` / `Hint` is treated as an implicit opt-in. - Explicit `IsInAccessibleTree="False"` (Raw) always wins over any opt-in. `GetClassNameCore` (cross-platform layout type name) and `IsKeyboardFocusableCore` (false) are unchanged from #35562. `GetAutomationControlTypeCore` now reports `Custom` for anonymous / AutomationId-only layouts and `Pane` only for explicit accessibility semantics. ### Tests `LayoutTests.Windows.cs` is updated to verify `AutomationId` through the peer, keep AutomationId-only layouts out of the Content view (quieter `Custom` role), and cover the opt-in paths (`IsInAccessibleTree`, `Description`, `Hint`), explicit `Raw` opt-out precedence, and whitespace-only semantic text. UI test coverage added in `Issue4715`. ### Validation This change is Windows-only. Windows CI must confirm the PublicAPI analyzer results (RS0016/RS0017), since `net-windows` cannot be built locally on macOS. ### Issues Fixed Follow-up refinement to #35562, which fixed #4715. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Vignesh-SF3580 <102575140+Vignesh-SF3580@users.noreply.github.com>
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!
Description of Change
This is the
net11.0version of #35597, rebased ontonet11.0.In addition to the Windows-only opt-in behavior from #35597, this PR actions the
.NET11.0TODO by makingMauiLayoutAutomationPeerpublic (class and constructor) and adding the requirednet-windowsPublicAPI entries for the type, constructor, and protected overrides.This supersedes #35597 for
net11.0.Validation
MauiLayoutAutomationPeerispublic partial, its constructor is public, and the 6 protected overrides match the 6override Microsoft.Maui.Platform.MauiLayoutAutomationPeer.*entries insrc/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt.net-windowscannot be built locally on macOS.