Skip to content
Merged
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": "[Fabric] Raising UIA Event if Toggle State Changes in Switch Component",
"packageName": "react-native-windows",
"email": "kvineeth@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <Fabric/AbiViewProps.h>
#include "CompositionDynamicAutomationProvider.h"
#include "RootComponentView.h"
#include "UiaHelpers.h"

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

Expand Down Expand Up @@ -80,6 +81,16 @@ void SwitchComponentView::updateProps(
m_visualUpdateRequired = true;
}

if (oldViewProps.value != newViewProps.value) {
if (UiaClientsAreListening()) {
winrt::Microsoft::ReactNative::implementation::UpdateUiaProperty(
EnsureUiaProvider(),
UIA_ToggleToggleStatePropertyId,
oldViewProps.value ? ToggleState_On : ToggleState_Off,
newViewProps.value ? ToggleState_On : ToggleState_Off);
}
}

Super::updateProps(props, oldProps);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ void UpdateUiaProperty(winrt::IInspectable provider, PROPERTYID propId, bool old
UiaRaiseAutomationPropertyChangedEvent(spProviderSimple.get(), propId, CComVariant(oldValue), CComVariant(newValue));
}

void UpdateUiaProperty(winrt::IInspectable provider, PROPERTYID propId, int oldValue, int 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 Down
6 changes: 6 additions & 0 deletions vnext/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ void UpdateUiaProperty(
bool oldValue,
bool newValue) noexcept;

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

void UpdateUiaProperty(
winrt::Windows::Foundation::IInspectable provider,
PROPERTYID propId,
Expand Down
Loading