Raise UIA events for selection changes - #16446
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.
🟢 Approval recommended
The implementation matches UI Automation selection semantics and includes focused coverage for the introduced behavior.
Pull request overview
Updates Fabric UI Automation selection handling so clients receive selection-state changes from the mounted component hierarchy.
Changes:
- Raises selection property changes and appropriate SelectionItem events.
- Replaces cached selections with mounted hierarchy traversal.
- Adds native tests for traversal and event classification.
File summaries
| File | Description |
|---|---|
UiaHelpers.h |
Declares selection traversal and event helpers. |
UiaHelpers.cpp |
Implements hierarchy enumeration and event dispatch. |
SelectionItemAutomationEvent.h |
Adds reusable selection logic. |
CompositionViewComponentView.cpp |
Raises events when mounted selection state changes. |
CompositionDynamicAutomationProvider.h |
Removes cached selection state. |
CompositionDynamicAutomationProvider.cpp |
Derives GetSelection from mounted views. |
UiaHelpersTests.cpp |
Tests state, traversal, and event behavior. |
Microsoft.ReactNative.IntegrationTests.vcxproj.filters |
Registers the test source. |
Microsoft.ReactNative.IntegrationTests.vcxproj |
Compiles the test source. |
react-native-windows-22b1e2a3-5ecc-4c5c-b127-e625595c8026.json |
Records the prerelease change. |
Review details
- Files reviewed: 10/10 changed files
- Comments generated: 0
- Review effort level: Balanced (auto)
Note
Copilot is running an experiment and ran this review at Balanced.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0f63ea4f-a16b-4fa3-b141-785aec89b5e4
There was a problem hiding this comment.
🟢 Approval recommended
The implementation consistently derives selection state from mounted views, handles COM array failures, and includes focused helper coverage for the introduced behavior.
Review details
- Files reviewed: 10/10 changed files
- Comments generated: 0 new
- Review effort level: Balanced (auto)
Note
Copilot is running an experiment and ran this review at Balanced.
This reverts commit e3d3f98.
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 bypass custom automation peers by using the inner provider as their source.
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
- Selection events for the changed item are raised from
m_innerAutomationProvider, while the property-change event immediately above uses the provider returned byEnsureUiaProvider(). When a component supplies a custom automation peer,EnsureUiaProvider()exposes that wrapper and the inner provider is only its default implementation, so this event can be attributed to a provider that is not the element exposed in the UIA tree (and may have a different runtime identity). Preserve the inner provider for finding the selection container, but raise the event from the publicprovider, as the existing focus and invoke event paths do.
- Files reviewed: 10/10 changed files
- Comments generated: 0 new
- Review effort level: Balanced (auto)
Note
Copilot is running an experiment and ran this review at Balanced.
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 bypass custom automation-peer wrappers, and the reported test count is stale.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 10/10 changed files
- Comments generated: 2
- Review effort level: Balanced (auto)
Note
Copilot is running an experiment and ran this review at Balanced.
| winrt::com_ptr<IRawElementProviderSimple> eventProvider; | ||
| eventProvider.copy_from(static_cast<IRawElementProviderSimple *>(provider)); |
| TestCheck(!winrt::Microsoft::ReactNative::implementation::ShouldRaiseSelectionItemNotification(true, false, false)); | ||
| } | ||
|
|
||
| TEST_METHOD(SelectionItemNotificationIncludesItemNameAndLocalizedState) { |
Description
Type of Change
Why
RNW Fabric exposes
accessibilityState.selectedthroughISelectionItemProvider::IsSelected, but it does not notify UI Automation clients when that state changes. Narrator therefore does not announce selection changes even when applications provide the correct Selection/SelectionItem semantics.This is a pre-existing RNW framework issue rather than a Gallery workaround or an RNW 0.85 regression. The relevant implementation predates 0.85, and the Gallery correctly provides selection-container state and per-item
accessibilityState.selected.Resolves ADO 63972808
What
UIA_SelectionItemIsSelectedPropertyIdchanges when mounted selection items change state.ISelectionProvider::GetSelectionreflect the mounted component hierarchy.Screenshots
Not applicable; this change affects UI Automation events.
Testing
Added native tests covering:
UiaHelpersTests.*: 9/9 passed. Changed production translation units compiled successfully. C++ formatting andgit diff --checkpass.The broader target remains blocked by a pre-existing React
ShadowTree.cppdependency mismatch unrelated to this change.Changelog
Yes.
Raise UI Automation selection events when
accessibilityState.selectedchanges.Microsoft Reviewers: Open in CodeFlow