Skip to content

Raise UIA events for selection changes - #16446

Open
anuagragith wants to merge 5 commits into
microsoft:mainfrom
anuagragith:fix/selection-item-automation-events
Open

anuagragith wants to merge 5 commits into
microsoft:mainfrom
anuagragith:fix/selection-item-automation-events

Conversation

@anuagragith

@anuagragith anuagragith commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Description

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Why

RNW Fabric exposes accessibilityState.selected through ISelectionItemProvider::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

  • Raise UIA_SelectionItemIsSelectedPropertyId changes when mounted selection items change state.
  • Raise the appropriate SelectionItem event for single and multiple selection.
  • Enumerate selected items from the currently mounted component hierarchy instead of a UIA-provider cache, excluding unmounted descendants and nested selection containers.
  • Avoid emitting misleading events for initial selected props before an item is mounted.
  • Make ISelectionProvider::GetSelection reflect the mounted component hierarchy.

Screenshots

Not applicable; this change affects UI Automation events.

Testing

Added native tests covering:

  • mounted and unmounted state transitions, including missing-as-false semantics;
  • hierarchy traversal, unmounted items, and nested selection containers;
  • single-selection and multi-selection event classification;
  • removal that leaves one selected item.

UiaHelpersTests.*: 9/9 passed. Changed production translation units compiled successfully. C++ formatting and git diff --check pass.

The broader target remains blocked by a pre-existing React ShadowTree.cpp dependency mismatch unrelated to this change.

Changelog

Yes.

Raise UI Automation selection events when accessibilityState.selected changes.

Microsoft Reviewers: Open in CodeFlow

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
@anuagragith
anuagragith requested a review from a team as a code owner September 16, 2026 23:41
Copilot AI balanced review requested due to automatic review settings September 16, 2026 23:41

Copilot AI 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.

🟢 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
Copilot AI review requested due to automatic review settings September 17, 2026 19:38

Copilot AI 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.

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

Copilot AI review requested due to automatic review settings September 17, 2026 19:56
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 0f63ea4f-a16b-4fa3-b141-785aec89b5e4

Copilot AI 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.

🔵 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 by EnsureUiaProvider(). 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 public provider, 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
Copilot AI review requested due to automatic review settings September 17, 2026 20:33

Copilot AI 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.

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

Comment on lines +565 to +566
winrt::com_ptr<IRawElementProviderSimple> eventProvider;
eventProvider.copy_from(static_cast<IRawElementProviderSimple *>(provider));
TestCheck(!winrt::Microsoft::ReactNative::implementation::ShouldRaiseSelectionItemNotification(true, false, false));
}

TEST_METHOD(SelectionItemNotificationIncludesItemNameAndLocalizedState) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants