Skip to content

Commit

Permalink
[0.76] Cherry-pick changes (#13982)
Browse files Browse the repository at this point in the history
* [Fabric] Implement IExpandCollapseProvider  (#13892)

* Implement IExpandCollapseProvider

* Change files

* Adjust Example

* Format + Update Snapshots

* [Fabric] implement tooltip property (#13941)

* [Fabric] implement view tooltip property

* format

* Change files

* update

* Fix lingering tooltip if component is unmounted while tooltip showing

* snapshot

---------

Co-authored-by: Jon Thysell <jthysell@microsoft.com>

* Fix RootComponentView leak (#13959)

* Fix RootComponentView leak

* Change files

* format

---------

Co-authored-by: React-Native-Windows Bot <53619745+rnbot@users.noreply.github.com>

* Add Support for AccessibilityState:Busy (#13952)

* Support AccessibilityState: Busy

* Change files

* Add Testing

* Update Snapshots

* Update for Leak

---------

Co-authored-by: Chiara Mooney <34109996+chiaramooney@users.noreply.github.com>
Co-authored-by: Jon Thysell <jthysell@microsoft.com>
Co-authored-by: React-Native-Windows Bot <53619745+rnbot@users.noreply.github.com>
  • Loading branch information
4 people authored Oct 16, 2024
1 parent e6a4c81 commit 37e97c2
Show file tree
Hide file tree
Showing 36 changed files with 731 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Support AccessibilityState: Busy",
"packageName": "react-native-windows",
"email": "34109996+chiaramooney@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Fix RootComponentView leak",
"packageName": "react-native-windows",
"email": "53619745+rnbot@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "[Fabric] implement view tooltip property",
"packageName": "react-native-windows",
"email": "30809111+acoates-ms@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Implement IExpandCollapseProvider",
"packageName": "react-native-windows",
"email": "34109996+chiaramooney@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ class AccessibilityExample extends React.Component<
> {
state: {tap: number} = {
tap: 0,
expanded: true,
};

render(): React.Node {
Expand All @@ -554,10 +555,10 @@ class AccessibilityExample extends React.Component<
accessibilityRole="button"
accessibilityValue={{now: this.state.tap}}
accessibilityActions={[
{name: 'cut', label: 'cut'},
{name: 'copy', label: 'copy'},
{name: 'paste', label: 'paste'},
{name: 'expand', label: 'expand'},
{name: 'collapse', label: 'collapse'},
]}
accessibilityState={{expanded: this.state.expanded, busy: true}}
accessibilityPosInSet={1}
accessibilitySetSize={1}
accessibilityLiveRegion='polite'
Expand All @@ -566,19 +567,19 @@ class AccessibilityExample extends React.Component<
focusable
onAccessibilityAction={event => {
switch (event.nativeEvent.actionName) {
case 'cut':
Alert.alert('Alert', 'cut action success');
break;
case 'copy':
Alert.alert('Alert', 'copy action success');
break;
case 'paste':
Alert.alert('Alert', 'paste action success');
case 'expand':
this.setState({expanded: true})
break;
case 'collapse':
this.setState({expanded: false})
}
}}
onAccessibilityTap={() => {
this.setState({tap: this.state.tap + 1});
}}
onPress={()=>{
this.setState({expanded: !this.state.expanded});
console.log('Pressed');
}}>
<Text>A View with accessibility values.</Text>
<Text>Current Number of Accessibility Taps: {this.state.tap}</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1094,8 +1094,10 @@ exports[`View Tests Views can have customized accessibility 1`] = `
"Automation Tree": {
"AutomationId": "accessibility",
"ControlType": 50000,
"ExpandCollapsePattern.ExpandCollapseState": "Expanded",
"HelpText": "Accessibility Hint",
"IsKeyboardFocusable": true,
"ItemStatus": "Busy",
"LiveSetting": "Polite",
"LocalizedControlType": "button",
"Name": "A View with accessibility values",
Expand Down Expand Up @@ -6084,12 +6086,24 @@ exports[`View Tests Views can have tooltips 1`] = `
"_Props": {},
},
{
"Type": "Microsoft.ReactNative.Composition.ParagraphComponentView",
"Type": "Microsoft.ReactNative.Composition.ViewComponentView",
"_Props": {},
"__Children": [
{
"Type": "Microsoft.ReactNative.Composition.ParagraphComponentView",
"_Props": {},
},
],
},
{
"Type": "Microsoft.ReactNative.Composition.ParagraphComponentView",
"Type": "Microsoft.ReactNative.Composition.ViewComponentView",
"_Props": {},
"__Children": [
{
"Type": "Microsoft.ReactNative.Composition.ParagraphComponentView",
"_Props": {},
},
],
},
],
},
Expand Down Expand Up @@ -6125,6 +6139,25 @@ exports[`View Tests Views can have tooltips 1`] = `
"Offset": "0, 0, 0",
"Size": "916, 15",
"Visual Type": "SpriteVisual",
"__Children": [
{
"Offset": "0, 0, 0",
"Size": "916, 15",
"Visual Type": "SpriteVisual",
"__Children": [
{
"Offset": "0, 0, 0",
"Size": "916, 15",
"Visual Type": "SpriteVisual",
},
{
"Offset": "0, 0, 0",
"Size": "0, 0",
"Visual Type": "SpriteVisual",
},
],
},
],
},
{
"Offset": "0, 0, 0",
Expand All @@ -6135,13 +6168,32 @@ exports[`View Tests Views can have tooltips 1`] = `
},
{
"Offset": "0, 29, 0",
"Size": "916, 16",
"Size": "916, 14",
"Visual Type": "SpriteVisual",
"__Children": [
{
"Offset": "0, 0, 0",
"Size": "916, 16",
"Size": "916, 14",
"Visual Type": "SpriteVisual",
"__Children": [
{
"Offset": "0, 0, 0",
"Size": "916, 16",
"Visual Type": "SpriteVisual",
"__Children": [
{
"Offset": "0, 0, 0",
"Size": "916, 16",
"Visual Type": "SpriteVisual",
},
{
"Offset": "0, 0, 0",
"Size": "0, 0",
"Visual Type": "SpriteVisual",
},
],
},
],
},
{
"Offset": "0, 0, 0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77745,16 +77745,12 @@ exports[`snapshotAllPages View 22`] = `
accessibilityActions={
[
{
"label": "cut",
"name": "cut",
"label": "expand",
"name": "expand",
},
{
"label": "copy",
"name": "copy",
},
{
"label": "paste",
"name": "paste",
"label": "collapse",
"name": "collapse",
},
]
}
Expand All @@ -77764,6 +77760,12 @@ exports[`snapshotAllPages View 22`] = `
accessibilityPosInSet={1}
accessibilityRole="button"
accessibilitySetSize={1}
accessibilityState={
{
"busy": true,
"expanded": true,
}
}
accessibilityValue={
{
"now": 0,
Expand All @@ -77773,6 +77775,7 @@ exports[`snapshotAllPages View 22`] = `
focusable={true}
onAccessibilityAction={[Function]}
onAccessibilityTap={[Function]}
onPress={[Function]}
testID="accessibility"
>
<Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,23 @@ void InsertToggleStateValueIfNotDefault(
}
}

void InsertExpandCollapseStateValueIfNotDefault(
const winrt::Windows::Data::Json::JsonObject &obj,
winrt::hstring name,
ExpandCollapseState value,
ExpandCollapseState defaultValue = ExpandCollapseState::ExpandCollapseState_Collapsed) {
if (value != defaultValue) {
switch (value) {
case 0:
obj.Insert(name, winrt::Windows::Data::Json::JsonValue::CreateStringValue(L"Collapsed"));
break;
case 1:
obj.Insert(name, winrt::Windows::Data::Json::JsonValue::CreateStringValue(L"Expanded"));
break;
}
}
}

winrt::Windows::Data::Json::JsonObject ListErrors(winrt::Windows::Data::Json::JsonValue payload) {
winrt::Windows::Data::Json::JsonObject result;
winrt::Windows::Data::Json::JsonArray jsonErrors;
Expand All @@ -339,6 +356,7 @@ void DumpUIAPatternInfo(IUIAutomationElement *pTarget, const winrt::Windows::Dat
BOOL isReadOnly;
ToggleState toggleState;
IValueProvider *valuePattern;
ExpandCollapseState expandCollapseState;
HRESULT hr;

// Dump IValueProvider Information
Expand All @@ -365,6 +383,18 @@ void DumpUIAPatternInfo(IUIAutomationElement *pTarget, const winrt::Windows::Dat
}
togglePattern->Release();
}

// Dump IExpandCollapseProvider Information
IExpandCollapseProvider *expandCollapsePattern;
hr = pTarget->GetCurrentPattern(UIA_ExpandCollapsePatternId, reinterpret_cast<IUnknown **>(&expandCollapsePattern));
if (SUCCEEDED(hr) && expandCollapsePattern) {
hr = expandCollapsePattern->get_ExpandCollapseState(&expandCollapseState);
if (SUCCEEDED(hr)) {
InsertExpandCollapseStateValueIfNotDefault(
result, L"ExpandCollapsePattern.ExpandCollapseState", expandCollapseState);
}
expandCollapsePattern->Release();
}
}

winrt::Windows::Data::Json::JsonObject DumpUIATreeRecurse(
Expand All @@ -381,6 +411,7 @@ winrt::Windows::Data::Json::JsonObject DumpUIATreeRecurse(
int positionInSet = 0;
int sizeOfSet = 0;
LiveSetting liveSetting = LiveSetting::Off;
BSTR itemStatus;

pTarget->get_CurrentAutomationId(&automationId);
pTarget->get_CurrentControlType(&controlType);
Expand All @@ -389,6 +420,7 @@ winrt::Windows::Data::Json::JsonObject DumpUIATreeRecurse(
pTarget->get_CurrentIsKeyboardFocusable(&isKeyboardFocusable);
pTarget->get_CurrentLocalizedControlType(&localizedControlType);
pTarget->get_CurrentName(&name);
pTarget->get_CurrentItemStatus(&itemStatus);
IUIAutomationElement4 *pTarget4;
HRESULT hr = pTarget->QueryInterface(__uuidof(IUIAutomationElement4), reinterpret_cast<void **>(&pTarget4));
if (SUCCEEDED(hr) && pTarget4) {
Expand All @@ -408,6 +440,7 @@ winrt::Windows::Data::Json::JsonObject DumpUIATreeRecurse(
InsertIntValueIfNotDefault(result, L"PositionInSet", positionInSet);
InsertIntValueIfNotDefault(result, L"SizeofSet", sizeOfSet);
InsertLiveSettingValueIfNotDefault(result, L"LiveSetting", liveSetting);
InsertStringValueIfNotEmpty(result, L"ItemStatus", itemStatus);
DumpUIAPatternInfo(pTarget, result);

IUIAutomationElement *pChild;
Expand All @@ -423,6 +456,11 @@ winrt::Windows::Data::Json::JsonObject DumpUIATreeRecurse(
if (children.Size() > 0) {
result.Insert(L"__Children", children);
}
::SysFreeString(automationId);
::SysFreeString(helpText);
::SysFreeString(localizedControlType);
::SysFreeString(name);
::SysFreeString(itemStatus);
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ exports[`ViewTests Views can have a custom nativeID 1`] = `
exports[`ViewTests Views can have accessibility customization 1`] = `
{
"AccessibilityRole": "Button",
"AccessibilityStateBusy": true,
"AccessibilityStateExpanded": true,
"AutomationId": "accessibility",
"AutomationPositionInSet": 1,
"AutomationSizeOfSet": 1,
Expand Down
1 change: 1 addition & 0 deletions vnext/Desktop.DLL/React.Windows.Desktop.DLL.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
comsuppw.lib;
Shlwapi.lib;
Version.lib;
Dwmapi.lib;
WindowsApp_downlevel.lib;
%(AdditionalDependencies)
</AdditionalDependencies>
Expand Down
12 changes: 12 additions & 0 deletions vnext/Microsoft.ReactNative/Fabric/ComponentView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <Fabric/Composition/RootComponentView.h>
#include "AbiEventEmitter.h"
#include "AbiShadowNode.h"
#include "ReactCoreInjection.h"

namespace winrt::Microsoft::ReactNative::Composition::implementation {
struct RootComponentView;
Expand Down Expand Up @@ -262,6 +263,17 @@ void ComponentView::HandleCommand(const winrt::Microsoft::ReactNative::HandleCom
}
}

HWND ComponentView::GetHwndForParenting() noexcept {
if (m_parent) {
return winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(m_parent)
->GetHwndForParenting();
}

// Fallback if we do not know any more specific HWND
return reinterpret_cast<HWND>(winrt::Microsoft::ReactNative::implementation::ReactCoreInjection::GetTopLevelWindowId(
m_reactContext.Properties().Handle()));
}

winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView *ComponentView::rootComponentView()
const noexcept {
if (m_rootView)
Expand Down
3 changes: 3 additions & 0 deletions vnext/Microsoft.ReactNative/Fabric/ComponentView.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ struct ComponentView : public ComponentViewT<ComponentView> {
// Notify up the tree to bring the rect into view by scrolling as needed
virtual void StartBringIntoView(BringIntoViewOptions &&args) noexcept;

// Eventually PopupContentLink and similar APIs will remove the need for this.
virtual HWND GetHwndForParenting() noexcept;

virtual const winrt::Microsoft::ReactNative::IComponentProps userProps(
facebook::react::Props::Shared const &props) noexcept;

Expand Down
Loading

0 comments on commit 37e97c2

Please sign in to comment.