Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Added UIA Event Triggers for accessibilityAnnotation Property Changes",
"packageName": "react-native-windows",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "adding UIA event handler changes for navigator",
"packageName": "react-native-windows",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,9 @@ HRESULT __stdcall CompositionDynamicAutomationProvider::Expand() {

if (!strongView)
return UIA_E_ELEMENTNOTAVAILABLE;

DispatchAccessibilityAction(m_view, "expand");

return S_OK;
}

Expand All @@ -1018,7 +1020,9 @@ HRESULT __stdcall CompositionDynamicAutomationProvider::Collapse() {

if (!strongView)
return UIA_E_ELEMENTNOTAVAILABLE;

DispatchAccessibilityAction(m_view, "collapse");

return S_OK;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,30 @@ void ComponentView::updateAccessibilityProps(
oldViewProps.accessibilityValue.text,
newViewProps.accessibilityValue.text);

// Handle annotation properties with single call
winrt::Microsoft::ReactNative::implementation::UpdateUiaPropertiesForAnnotation(
EnsureUiaProvider(), oldViewProps.accessibilityAnnotation, newViewProps.accessibilityAnnotation);

// Handle expand/collapse state changes
if (oldViewProps.accessibilityState.has_value() != newViewProps.accessibilityState.has_value() ||
(oldViewProps.accessibilityState.has_value() && newViewProps.accessibilityState.has_value() &&
oldViewProps.accessibilityState->expanded != newViewProps.accessibilityState->expanded)) {
auto oldExpanded =
oldViewProps.accessibilityState.has_value() && oldViewProps.accessibilityState->expanded.has_value()
? oldViewProps.accessibilityState->expanded.value()
: false;
auto newExpanded =
newViewProps.accessibilityState.has_value() && newViewProps.accessibilityState->expanded.has_value()
? newViewProps.accessibilityState->expanded.value()
: false;

winrt::Microsoft::ReactNative::implementation::UpdateUiaProperty(
EnsureUiaProvider(),
UIA_ExpandCollapseExpandCollapseStatePropertyId,
static_cast<int>(winrt::Microsoft::ReactNative::implementation::GetExpandCollapseState(oldExpanded)),
static_cast<int>(winrt::Microsoft::ReactNative::implementation::GetExpandCollapseState(newExpanded)));
}

if ((oldViewProps.accessibilityState.has_value() && oldViewProps.accessibilityState->selected.has_value()) !=
((newViewProps.accessibilityState.has_value() && newViewProps.accessibilityState->selected.has_value()))) {
auto compProvider =
Expand Down
32 changes: 32 additions & 0 deletions vnext/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@ void UpdateUiaProperty(winrt::IInspectable provider, PROPERTYID propId, int oldV
UiaRaiseAutomationPropertyChangedEvent(spProviderSimple.get(), propId, CComVariant(oldValue), CComVariant(newValue));
}

void UpdateUiaProperty(winrt::IInspectable provider, PROPERTYID propId, long oldValue, long newValue) noexcept {
auto spProviderSimple = provider.try_as<IRawElementProviderSimple>();

if (spProviderSimple == nullptr || oldValue == newValue || !WasUiaPropertyAdvised(spProviderSimple, propId))
return;

UiaRaiseAutomationPropertyChangedEvent(spProviderSimple.get(), propId, CComVariant(oldValue), CComVariant(newValue));
}

void UpdateUiaProperty(
winrt::IInspectable provider,
PROPERTYID propId,
Expand All @@ -199,6 +208,29 @@ void UpdateUiaProperty(
UpdateUiaProperty(provider, propId, oldData, newData);
}

void UpdateUiaPropertiesForAnnotation(
winrt::IInspectable provider,
const std::optional<facebook::react::AccessibilityAnnotation> &oldAnnotation,
const std::optional<facebook::react::AccessibilityAnnotation> &newAnnotation) noexcept {
// if no value fall back to a default value.
const auto &old_annotation = oldAnnotation.value_or(facebook::react::AccessibilityAnnotation());
const auto &new_annotation = newAnnotation.value_or(facebook::react::AccessibilityAnnotation());

// Update all annotation properties
UpdateUiaProperty(
provider,
UIA_AnnotationAnnotationTypeIdPropertyId,
GetAnnotationTypeId(old_annotation.typeID),
GetAnnotationTypeId(new_annotation.typeID));

UpdateUiaProperty(
provider, UIA_AnnotationAnnotationTypeNamePropertyId, old_annotation.typeName, new_annotation.typeName);

UpdateUiaProperty(provider, UIA_AnnotationAuthorPropertyId, old_annotation.author, new_annotation.author);

UpdateUiaProperty(provider, UIA_AnnotationDateTimePropertyId, old_annotation.dateTime, new_annotation.dateTime);
}

long GetLiveSetting(const std::string &liveRegion) noexcept {
if (liveRegion == "polite") {
return LiveSetting::Polite;
Expand Down
11 changes: 11 additions & 0 deletions vnext/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ void UpdateUiaProperty(
int oldValue,
int newValue) noexcept;

void UpdateUiaProperty(
winrt::Windows::Foundation::IInspectable provider,
PROPERTYID propId,
long oldValue,
long newValue) noexcept;

void UpdateUiaProperty(
winrt::Windows::Foundation::IInspectable provider,
PROPERTYID propId,
Expand All @@ -47,6 +53,11 @@ void UpdateUiaProperty(
const std::optional<std::string> &oldValue,
const std::optional<std::string> &newValue) noexcept;

void UpdateUiaPropertiesForAnnotation(
winrt::Windows::Foundation::IInspectable provider,
const std::optional<facebook::react::AccessibilityAnnotation> &oldAnnotation,
const std::optional<facebook::react::AccessibilityAnnotation> &newAnnotation) noexcept;

long GetLiveSetting(const std::string &liveRegion) noexcept;

long GetAnnotationTypeId(const std::string &annotationType) noexcept;
Expand Down
Loading