@@ -171,24 +171,6 @@ ContentIslandComponentView::~ContentIslandComponentView() noexcept {
171171 m_navigationHost.DepartFocusRequested (m_navigationHostDepartFocusRequestedToken);
172172 m_navigationHostDepartFocusRequestedToken = {};
173173 }
174- if (m_childSiteLink) {
175- if (m_fragmentRootAutomationProviderRequestedToken) {
176- m_childSiteLink.FragmentRootAutomationProviderRequested (m_fragmentRootAutomationProviderRequestedToken);
177- m_fragmentRootAutomationProviderRequestedToken = {};
178- }
179- if (m_parentAutomationProviderRequestedToken) {
180- m_childSiteLink.ParentAutomationProviderRequested (m_parentAutomationProviderRequestedToken);
181- m_parentAutomationProviderRequestedToken = {};
182- }
183- if (m_nextSiblingAutomationProviderRequestedToken) {
184- m_childSiteLink.NextSiblingAutomationProviderRequested (m_nextSiblingAutomationProviderRequestedToken);
185- m_nextSiblingAutomationProviderRequestedToken = {};
186- }
187- if (m_previousSiblingAutomationProviderRequestedToken) {
188- m_childSiteLink.PreviousSiblingAutomationProviderRequested (m_previousSiblingAutomationProviderRequestedToken);
189- m_previousSiblingAutomationProviderRequestedToken = {};
190- }
191- }
192174 if (m_islandToConnect) {
193175 m_islandToConnect.Close ();
194176 }
@@ -230,56 +212,13 @@ void ContentIslandComponentView::prepareForRecycle() noexcept {
230212}
231213
232214void ContentIslandComponentView::ConfigureChildSiteLinkAutomation () noexcept {
233- // This automation mode must be set before connecting the child ContentIsland.
234- // It puts the child content into a mode where it won't own its own framework root. Instead, the child island's
235- // automation peers will use the same framework root as the automation peer of this ContentIslandComponentView.
236- m_childSiteLink.AutomationOption (winrt::Microsoft::UI::Content::ContentAutomationOptions::FragmentBased);
237-
238- // These events are raised in response to the child ContentIsland asking for providers.
239- // For example, the ContentIsland.FragmentRootAutomationProvider property will return
240- // the provider we provide here in FragmentRootAutomationProviderRequested.
241-
242- // We capture "this" as a raw pointer because ContentIslandComponentView doesn't currently support weak ptrs.
243- // It's safe because we disconnect these events in the destructor.
244-
245- m_fragmentRootAutomationProviderRequestedToken = m_childSiteLink.FragmentRootAutomationProviderRequested (
246- [this ](
247- const winrt::Microsoft::UI::Content::IContentSiteAutomation &,
248- const winrt::Microsoft::UI::Content::ContentSiteAutomationProviderRequestedEventArgs &args) {
249- // The child island's fragment tree doesn't have its own fragment root.
250- // Here's how we can provide the correct fragment root to the child's UIA logic.
251- winrt::com_ptr<IRawElementProviderFragmentRoot> fragmentRoot{nullptr };
252- auto uiaProvider = this ->EnsureUiaProvider ();
253- uiaProvider.as <IRawElementProviderFragment>()->get_FragmentRoot (fragmentRoot.put ());
254- args.AutomationProvider (fragmentRoot.as <IInspectable>());
255- args.Handled (true );
256- });
257-
258- m_parentAutomationProviderRequestedToken = m_childSiteLink.ParentAutomationProviderRequested (
259- [this ](
260- const winrt::Microsoft::UI::Content::IContentSiteAutomation &,
261- const winrt::Microsoft::UI::Content::ContentSiteAutomationProviderRequestedEventArgs &args) {
262- auto uiaProvider = this ->EnsureUiaProvider ();
263- args.AutomationProvider (uiaProvider);
264- args.Handled (true );
265- });
266-
267- m_nextSiblingAutomationProviderRequestedToken = m_childSiteLink.NextSiblingAutomationProviderRequested (
268- [](const winrt::Microsoft::UI::Content::IContentSiteAutomation &,
269- const winrt::Microsoft::UI::Content::ContentSiteAutomationProviderRequestedEventArgs &args) {
270- // The ContentIsland will always be the one and only child of this node, so it won't have siblings.
271- args.AutomationProvider (nullptr );
272- args.Handled (true );
273- });
274-
275- m_previousSiblingAutomationProviderRequestedToken = m_childSiteLink.PreviousSiblingAutomationProviderRequested (
276- [](const winrt::Microsoft::UI::Content::IContentSiteAutomation &,
277- const winrt::Microsoft::UI::Content::ContentSiteAutomationProviderRequestedEventArgs &args) {
278- // The ContentIsland will always be the one and only child of this node, so it won't have siblings.
279- args.AutomationProvider (nullptr );
280- args.Handled (true );
281- });
215+ // Use FrameworkBased to let the XamlIsland manage its own framework-level accessibility tree
216+ // and raise focus events naturally. This tells the system that the child island has its own
217+ // framework (WinUI/XAML) that manages automation.
218+ m_childSiteLink.AutomationOption (winrt::Microsoft::UI::Content::ContentAutomationOptions::FrameworkBased);
282219
220+ // When using FrameworkBased mode, we don't register automation callbacks - let the XamlIsland handle its own UIA
221+ // tree.
283222 if (m_innerAutomationProvider) {
284223 m_innerAutomationProvider->SetChildSiteLink (m_childSiteLink);
285224 }
0 commit comments