diff --git a/change/react-native-windows-26d524ee-3303-4cbf-a1d5-2c876d58c088.json b/change/react-native-windows-26d524ee-3303-4cbf-a1d5-2c876d58c088.json new file mode 100644 index 00000000000..45906b1bd99 --- /dev/null +++ b/change/react-native-windows-26d524ee-3303-4cbf-a1d5-2c876d58c088.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "Properly hook up root uia provider to island", + "packageName": "react-native-windows", + "email": "30809111+acoates-ms@users.noreply.github.com", + "dependentChangeType": "patch" +} diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp index 54dcb52dc20..3dce49c0146 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp @@ -376,11 +376,12 @@ winrt::IInspectable ReactNativeIsland::GetUiaProvider() noexcept { if (m_uiaProvider == nullptr) { m_uiaProvider = winrt::make(*this); - if (m_hwnd && !m_island) { + if (m_hwnd || m_island) { auto pRootProvider = static_cast( m_uiaProvider.as().get()); if (pRootProvider != nullptr) { + pRootProvider->SetIsland(m_island); pRootProvider->SetHwnd(m_hwnd); } } @@ -875,14 +876,7 @@ winrt::Microsoft::UI::Content::ContentIsland ReactNativeIsland::Island() { winrt::Microsoft::UI::Content::ContentIsland const &, winrt::Microsoft::UI::Content::ContentIslandAutomationProviderRequestedEventArgs const &args) { if (auto pThis = weakThis.get()) { - auto provider = pThis->GetUiaProvider(); - auto pRootProvider = - static_cast( - provider.as().get()); - if (pRootProvider != nullptr) { - pRootProvider->SetIsland(pThis->m_island); - } - args.AutomationProvider(std::move(provider)); + args.AutomationProvider(pThis->GetUiaProvider()); args.Handled(true); } });