[0.85] Raise UIA events for selection changes - #16447
anuagragith wants to merge 5 commits into
Conversation
Notify UI Automation clients when accessibilityState.selected changes and raise SelectionItem events according to the container's selection mode and selected item count. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0f63ea4f-a16b-4fa3-b141-785aec89b5e4
There was a problem hiding this comment.
🟡 Changes recommended
Selection events may not reach custom automation-provider wrappers.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Backports UI Automation selection-change notifications to the RNW 0.85 release line.
Changes:
- Raises selected-property and SelectionItem UIA events.
- Traverses mounted selection hierarchies.
- Adds tests, project integration, and changelog metadata.
File summaries
| File | Description |
|---|---|
vnext/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h |
Declares selection helpers. |
vnext/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp |
Implements selection traversal and event raising. |
vnext/Microsoft.ReactNative/Fabric/Composition/SelectionItemAutomationEvent.h |
Adds selection event logic. |
vnext/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp |
Emits UIA notifications on selection changes. |
vnext/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.h |
Updates selection state handling. |
vnext/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp |
Computes current selections dynamically. |
vnext/Microsoft.ReactNative.IntegrationTests/UiaHelpersTests.cpp |
Tests selection behavior and event classification. |
vnext/Microsoft.ReactNative.IntegrationTests/Microsoft.ReactNative.IntegrationTests.vcxproj.filters |
Adds test project filters. |
vnext/Microsoft.ReactNative.IntegrationTests/Microsoft.ReactNative.IntegrationTests.vcxproj |
Includes the new tests. |
change/react-native-windows-22b1e2a3-5ecc-4c5c-b127-e625595c8026.json |
Records the changelog entry. |
Review details
- Files reviewed: 10/10 changed files
- Comments generated: 1
- Review effort level: Lite (auto)
Note
Copilot is running an experiment and ran this review at Lite.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (m_innerAutomationProvider) { | ||
| winrt::Microsoft::ReactNative::implementation::RaiseSelectionItemAutomationEvent( | ||
| m_innerAutomationProvider.get(), newSelected.value_or(false)); |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0f63ea4f-a16b-4fa3-b141-785aec89b5e4
There was a problem hiding this comment.
🟡 Changes recommended
Selection events currently use the inner provider instead of the exposed provider, so custom automation peers may not receive them.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 10/10 changed files
- Comments generated: 1
- Review effort level: Lite (auto)
Note
Copilot is running an experiment and ran this review at Lite.
| winrt::Microsoft::ReactNative::implementation::RaiseSelectionItemAutomationEvent( | ||
| m_innerAutomationProvider.get(), newSelected.value_or(false), root && root->GetFocusedComponent() == *this); |
This reverts commit 3811196.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0f63ea4f-a16b-4fa3-b141-785aec89b5e4
There was a problem hiding this comment.
🔵 Needs a closer look
Selection events must be raised on the outer provider returned by EnsureUiaProvider() to support custom automation peers.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
vnext/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp:1291
- This raises the selection event on
m_innerAutomationProvider, bypassing the provider returned byEnsureUiaProvider(). When a component supplies a custom automation peer,EnsureUiaProvider()returns that wrapper whilem_innerAutomationProviderremains only the default provider (seeComponentView::EnsureUiaProvider); UIA clients listen to the wrapper, so these selection events are not delivered for custom peers. Keep the inner provider for finding the selection container, but raise the event on the outer provider returned byEnsureUiaProvider()(including the remaining-item provider in the single-item transition).
- Files reviewed: 10/10 changed files
- Comments generated: 0 new
- Review effort level: Lite (auto)
Note
Copilot is running an experiment and ran this review at Lite.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0f63ea4f-a16b-4fa3-b141-785aec89b5e4
There was a problem hiding this comment.
🔵 Needs a closer look
SelectionItem events may be raised from the inner provider instead of the exposed custom provider.
Review details
Suppressed comments (1)
vnext/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp:1292
- This raises the SelectionItem event on
m_innerAutomationProvider, butEnsureUiaProvider()can return a custom automation-peer wrapper whilem_innerAutomationProviderremains the default provider. In that case the event is sourced from a provider that is not the one exposed in the UIA tree, so custom peers will not receive/identify selection changes correctly. Pass the outer provider to the event-raising helper (use the inner provider only to inspect the selection container), matching theEnsureUiaProvider()path used for the property change above.
if (m_innerAutomationProvider) {
auto root = rootComponentView();
winrt::Microsoft::ReactNative::implementation::RaiseSelectionItemAutomationEvent(
m_innerAutomationProvider.get(), newSelected.value_or(false), root && root->GetFocusedComponent() == *this);
- Files reviewed: 10/10 changed files
- Comments generated: 0 new
- Review effort level: Lite (auto)
Note
Copilot is running an experiment and ran this review at Lite.
Description
Backports #16446 to .85-stable for the RNW 0.85 Gallery accessibility release.
Type of Change
Why
Narrator does not receive UI Automation notifications when �ccessibilityState.selected changes. The Gallery supplies the correct Selection/SelectionItem accessibility state, so the framework must emit the selected-property and SelectionItem events.
Resolves ADO 63972808 for the RNW 0.85 release line.
What
Clean cherry-pick of the main fix onto .85-stable.
Screenshots
Not applicable; this change affects UI Automation events.
Testing
The backport cherry-picked without conflicts. On the main fix, UiaHelpersTests.* passed 9/9, changed production translation units compiled, and formatting/diff checks passed.
Changelog
Yes.
Raise UI Automation selection events when �ccessibilityState.selected changes.
Microsoft Reviewers: Open in CodeFlow