Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "[Fabric] Implement announceForAccessibility in AccessibiltyInfo Module",
Comment thread
vineethkuttan marked this conversation as resolved.
Outdated
"packageName": "react-native-windows",
"email": "kvineeth@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@

namespace winrt::Microsoft::ReactNative::implementation {

ReactPropertyId<winrt::Microsoft::ReactNative::ReactNativeIsland>
ReactNativeIsland::ReactNativeIslandProperty() noexcept {
Comment thread
vineethkuttan marked this conversation as resolved.
Outdated
static const ReactPropertyId<winrt::Microsoft::ReactNative::ReactNativeIsland> prop{
L"ReactNative.Composition", L"ReactNativeIsland"};
Comment thread
vineethkuttan marked this conversation as resolved.
Outdated
return prop;
}
constexpr float loadingActivitySize = 12.0f;
constexpr float loadingActivityHorizontalOffset = 16.0f;
constexpr float loadingBarHeight = 36.0f;
Expand Down Expand Up @@ -861,6 +867,18 @@ winrt::Microsoft::UI::Content::ContentIsland ReactNativeIsland::Island() {
}
}
});
focusController.GotFocus(
[weakThis = get_weak()](const auto &sender, const winrt::Microsoft::UI::Input::FocusChangedEventArgs &args) {
if (auto pThis = weakThis.get()) {
// Set the island to React context so it can be accessed by native modules
if (pThis->m_context && pThis->m_island) {
auto properties = pThis->m_context.Properties();
properties.Set(
ReactNativeIsland::ReactNativeIslandProperty(),
pThis->get_strong().as<winrt::Microsoft::ReactNative::ReactNativeIsland>());
}
}
});

// ContentIsland does not support weak_ref, so we cannot use auto_revoke for these events
m_islandAutomationProviderRequestedToken = m_island.AutomationProviderRequested(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ struct ReactNativeIsland
~ReactNativeIsland() noexcept;

ReactNativeIsland(const winrt::Microsoft::UI::Composition::Compositor &compositor) noexcept;
static ReactPropertyId<winrt::Microsoft::ReactNative::ReactNativeIsland> ReactNativeIslandProperty() noexcept;
ReactNativeIsland(const winrt::Microsoft::ReactNative::Composition::PortalComponentView &portal) noexcept;

static winrt::Microsoft::ReactNative::ReactNativeIsland CreatePortal(
Expand Down
31 changes: 31 additions & 0 deletions vnext/Microsoft.ReactNative/Modules/AccessibilityInfoModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <UI.Xaml.Automation.Peers.h>
#include <UI.Xaml.Controls.h>
#include <XamlUtils.h>
#else
#include <Fabric/Composition/ReactNativeIsland.h>
#endif
#include <uiautomationcore.h>
#include <uiautomationcoreapi.h>
Expand Down Expand Up @@ -79,6 +81,35 @@ void AccessibilityInfo::announceForAccessibility(std::wstring announcement) noex
xaml::Automation::Peers::AutomationNotificationProcessing::ImportantMostRecent,
hstr,
hstr);
#else
if (auto reactNativeIsland = context.Properties().Get(
winrt::Microsoft::ReactNative::implementation::ReactNativeIsland::ReactNativeIslandProperty())) {
// Now you have access to the ReactNativeIsland
// You can get the ContentIsland from it if needed:
if (auto uiaprovider = reactNativeIsland.GetUiaProvider()) {
if (auto rawProvider = uiaprovider.try_as<IRawElementProviderSimple>()) {
// Convert announcement to BSTR for UIA
winrt::hstring hstrAnnouncement{announcement};
auto bstrAnnouncement = SysAllocString(hstrAnnouncement.c_str());
auto bstrDisplayString = SysAllocString(hstrAnnouncement.c_str());

if (bstrAnnouncement && bstrDisplayString) {
Comment thread
vineethkuttan marked this conversation as resolved.
Outdated
// Raise the UIA notification event
HRESULT hr = UiaRaiseNotificationEvent(
rawProvider.get(),
NotificationKind_Other,
NotificationProcessing_ImportantMostRecent,
bstrDisplayString,
bstrAnnouncement);

// Clean up BSTRs
SysFreeString(bstrAnnouncement);
SysFreeString(bstrDisplayString);
Comment thread
vineethkuttan marked this conversation as resolved.
Outdated
}
}
}
}

#endif
});
}
Expand Down
Loading