@@ -129,6 +129,24 @@ HRESULT __stdcall CompositionDynamicAutomationProvider::GetPatternProvider(PATTE
129129
130130 *pRetVal = nullptr ;
131131
132+ auto strongView = m_view.view ();
133+ if (strongView == nullptr )
134+ return UIA_E_ELEMENTNOTAVAILABLE;
135+
136+ auto props = std::static_pointer_cast<const facebook::react::ViewProps>(strongView->props ());
137+ if (props == nullptr )
138+ return UIA_E_ELEMENTNOTAVAILABLE;
139+ auto accessibilityRole = props->accessibilityRole ;
140+ // Invoke control pattern is used to support controls that do not maintain state
141+ // when activated but rather initiate or perform a single, unambiguous action.
142+ if (patternId == UIA_InvokePatternId &&
143+ (accessibilityRole == " button" || accessibilityRole == " imagebutton" || accessibilityRole == " link" ||
144+ accessibilityRole == " splitbutton" || (accessibilityRole == " menuitem" && props->onAccessibilityTap ) ||
145+ (accessibilityRole == " treeitem" && props->onAccessibilityTap ))) {
146+ *pRetVal = static_cast <IInvokeProvider *>(this );
147+ AddRef ();
148+ }
149+
132150 return S_OK;
133151}
134152
@@ -278,4 +296,24 @@ HRESULT __stdcall CompositionDynamicAutomationProvider::get_HostRawElementProvid
278296 return S_OK;
279297}
280298
299+ HRESULT __stdcall CompositionDynamicAutomationProvider::Invoke () {
300+ auto strongView = m_view.view ();
301+
302+ if (!strongView)
303+ return UIA_E_ELEMENTNOTAVAILABLE;
304+
305+ auto baseView = std::static_pointer_cast<::Microsoft::ReactNative::CompositionBaseComponentView>(strongView);
306+ if (baseView == nullptr )
307+ return UIA_E_ELEMENTNOTAVAILABLE;
308+
309+ baseView.get ()->GetEventEmitter ().get ()->onAccessibilityTap ();
310+ auto uiaProvider = baseView->EnsureUiaProvider ();
311+ auto spProviderSimple = uiaProvider.try_as <IRawElementProviderSimple>();
312+ if (spProviderSimple != nullptr ) {
313+ UiaRaiseAutomationEvent (spProviderSimple.get (), UIA_Invoke_InvokedEventId);
314+ }
315+
316+ return S_OK;
317+ }
318+
281319} // namespace winrt::Microsoft::ReactNative::implementation
0 commit comments