diff --git a/change/react-native-windows-cdc988c8-8058-4f35-a668-0fc97bf4f9a8.json b/change/react-native-windows-cdc988c8-8058-4f35-a668-0fc97bf4f9a8.json new file mode 100644 index 00000000000..ee7da3a9438 --- /dev/null +++ b/change/react-native-windows-cdc988c8-8058-4f35-a668-0fc97bf4f9a8.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "Expose AutomationOption Setter for ChildSite", + "packageName": "react-native-windows", + "email": "66076509+vineethkuttan@users.noreply.github.com", + "dependentChangeType": "patch" +} \ No newline at end of file diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp index 1d49b7eb8d3..67be950c830 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp @@ -253,13 +253,14 @@ void ContentIslandComponentView::prepareForRecycle() noexcept { } void ContentIslandComponentView::ConfigureChildSiteLinkAutomation() noexcept { - // Use FrameworkBased to let the XamlIsland manage its own framework-level accessibility tree - // and raise focus events naturally. This tells the system that the child island has its own - // framework (WinUI/XAML) that manages automation. - m_childSiteLink.AutomationOption(winrt::Microsoft::UI::Content::ContentAutomationOptions::FrameworkBased); + // Determine the automation option to use: + // 1. If explicitly set via builder, use that + // 2. Otherwise, default to FrameworkBased + if (m_builder) { + m_childSiteLink.AutomationOption(m_builder->ContentIslandChildSiteAutomationOption().value_or( + winrt::Microsoft::UI::Content::ContentAutomationOptions::FrameworkBased)); + } - // When using FrameworkBased mode, we don't register automation callbacks - let the XamlIsland handle its own UIA - // tree. if (m_innerAutomationProvider) { m_innerAutomationProvider->SetChildSiteLink(m_childSiteLink); } diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp index c9f250f1e06..3e26bdf2355 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp @@ -113,6 +113,16 @@ void ReactCompositionViewComponentBuilder::SetContentIslandComponentViewInitiali }; } +void ReactCompositionViewComponentBuilder::SetContentIslandChildSiteAutomationOption( + winrt::Microsoft::UI::Content::ContentAutomationOptions automationOption) noexcept { + m_contentIslandChildSiteAutomationOption = automationOption; +} + +std::optional +ReactCompositionViewComponentBuilder::ContentIslandChildSiteAutomationOption() const noexcept { + return m_contentIslandChildSiteAutomationOption; +} + void ReactCompositionViewComponentBuilder::SetPortalComponentViewInitializer( const PortalComponentViewInitializer &initializer) noexcept { m_fnCreateView = [initializer]( diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h b/vnext/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h index c015b33a5fb..116764a2469 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h @@ -5,6 +5,7 @@ #include #include #include +#include #include "winrt/Microsoft.ReactNative.Composition.Experimental.h" #include "winrt/Microsoft.ReactNative.Composition.h" #include "winrt/Microsoft.ReactNative.h" @@ -46,6 +47,8 @@ struct ReactCompositionViewComponentBuilder public: // Composition::IReactCompositionViewComponentBuilder void SetViewComponentViewInitializer(const ViewComponentViewInitializer &initializer) noexcept; void SetContentIslandComponentViewInitializer(const ComponentIslandComponentViewInitializer &initializer) noexcept; + void SetContentIslandChildSiteAutomationOption( + winrt::Microsoft::UI::Content::ContentAutomationOptions automationOption) noexcept; void SetPortalComponentViewInitializer(const PortalComponentViewInitializer &initializer) noexcept; void SetCreateVisualHandler(CreateVisualDelegate impl) noexcept; void SetViewFeatures(ComponentViewFeatures viewFeatures) noexcept; @@ -81,6 +84,8 @@ struct ReactCompositionViewComponentBuilder const winrt::Microsoft::ReactNative::Composition::Experimental::IVisualToMountChildrenIntoDelegate & VisualToMountChildrenIntoHandler() const noexcept; const CreateAutomationPeerDelegate &CreateAutomationPeerHandler() const noexcept; + std::optional ContentIslandChildSiteAutomationOption() + const noexcept; private: void InitializeComponentView(const winrt::Microsoft::ReactNative::ComponentView &view) noexcept; @@ -114,6 +119,7 @@ struct ReactCompositionViewComponentBuilder m_visualToMountChildrenIntoHandler; UpdateLayoutMetricsDelegate m_updateLayoutMetricsHandler; bool m_xamlSupport{false}; + std::optional m_contentIslandChildSiteAutomationOption; }; } // namespace winrt::Microsoft::ReactNative::Composition diff --git a/vnext/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl b/vnext/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl index 4ddbdc43b54..bbc7fd90187 100644 --- a/vnext/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +++ b/vnext/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl @@ -21,6 +21,7 @@ namespace Microsoft.ReactNative.Composition [experimental] delegate void ComponentIslandComponentViewInitializer(ContentIslandComponentView view); + [webhosthidden] [experimental] delegate void PortalComponentViewInitializer(PortalComponentView view); @@ -68,6 +69,7 @@ namespace Microsoft.ReactNative.Composition { void SetViewComponentViewInitializer(ViewComponentViewInitializer initializer); void SetContentIslandComponentViewInitializer(ComponentIslandComponentViewInitializer initializer); + void SetContentIslandChildSiteAutomationOption(Microsoft.UI.Content.ContentAutomationOptions automationOption); void SetPortalComponentViewInitializer(PortalComponentViewInitializer initializer); void SetCreateVisualHandler(CreateVisualDelegate impl); void SetViewFeatures(ComponentViewFeatures viewFeatures);