Skip to content

Commit 47b2709

Browse files
authored
Ensure island on automation provider (#15414)
* Assert on text input focus when no UIA tool running * Change files
1 parent e716427 commit 47b2709

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Assert on text input focus when no UIA tool running",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

vnext/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -966,12 +966,17 @@ void CompositionEventHandler::getTargetPointerArgs(
966966
assert(m_pointerCapturingComponentTag != -1);
967967
tag = m_pointerCapturingComponentTag;
968968

969-
auto targetComponentView = fabricuiManager->GetViewRegistry().componentViewDescriptorWithTag(tag).view;
970-
auto clientRect = winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(targetComponentView)
971-
->getClientRect();
972-
if (auto strongRootView = m_wkRootView.get()) {
973-
ptLocal.x = ptScaled.x - (clientRect.left / strongRootView.ScaleFactor());
974-
ptLocal.y = ptScaled.y - (clientRect.top / strongRootView.ScaleFactor());
969+
auto targetComponentView = fabricuiManager->GetViewRegistry().findComponentViewWithTag(tag);
970+
if (targetComponentView) {
971+
auto clientRect =
972+
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(targetComponentView)
973+
->getClientRect();
974+
if (auto strongRootView = m_wkRootView.get()) {
975+
ptLocal.x = ptScaled.x - (clientRect.left / strongRootView.ScaleFactor());
976+
ptLocal.y = ptScaled.y - (clientRect.top / strongRootView.ScaleFactor());
977+
}
978+
} else {
979+
tag = -1;
975980
}
976981
} else {
977982
tag = RootComponentView().hitTest(ptScaled, ptLocal);

vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,12 @@ winrt::IInspectable ReactNativeIsland::GetUiaProvider() noexcept {
374374
if (m_uiaProvider == nullptr) {
375375
m_uiaProvider =
376376
winrt::make<winrt::Microsoft::ReactNative::implementation::CompositionRootAutomationProvider>(*this);
377-
if (m_hwnd && !m_island) {
378-
auto pRootProvider =
379-
static_cast<winrt::Microsoft::ReactNative::implementation::CompositionRootAutomationProvider *>(
380-
m_uiaProvider.as<IRawElementProviderSimple>().get());
381-
if (pRootProvider != nullptr) {
382-
pRootProvider->SetHwnd(m_hwnd);
383-
}
377+
auto pRootProvider =
378+
static_cast<winrt::Microsoft::ReactNative::implementation::CompositionRootAutomationProvider *>(
379+
m_uiaProvider.as<IRawElementProviderSimple>().get());
380+
if (pRootProvider != nullptr) {
381+
pRootProvider->SetIsland(m_island);
382+
pRootProvider->SetHwnd(m_hwnd);
384383
}
385384
}
386385
return m_uiaProvider;
@@ -868,9 +867,6 @@ winrt::Microsoft::UI::Content::ContentIsland ReactNativeIsland::Island() {
868867
auto pRootProvider =
869868
static_cast<winrt::Microsoft::ReactNative::implementation::CompositionRootAutomationProvider *>(
870869
provider.as<IRawElementProviderSimple>().get());
871-
if (pRootProvider != nullptr) {
872-
pRootProvider->SetIsland(pThis->m_island);
873-
}
874870
args.AutomationProvider(std::move(provider));
875871
args.Handled(true);
876872
}

0 commit comments

Comments
 (0)