From 55324c5a5ec969d63a192a3e40095311208a1f17 Mon Sep 17 00:00:00 2001 From: TatianaKapos Date: Tue, 19 Jul 2022 11:13:19 -0700 Subject: [PATCH 1/3] Implement no-hide-accessibility --- .../Libraries/Components/View/View.win32.js | 32 +++++++++++++++++++ .../Libraries/Components/View/View.windows.js | 32 +++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/packages/@office-iss/react-native-win32/src/Libraries/Components/View/View.win32.js b/packages/@office-iss/react-native-win32/src/Libraries/Components/View/View.win32.js index b9050da9042..aa093c8c4ca 100644 --- a/packages/@office-iss/react-native-win32/src/Libraries/Components/View/View.win32.js +++ b/packages/@office-iss/react-native-win32/src/Libraries/Components/View/View.win32.js @@ -75,6 +75,26 @@ const View: React.AbstractComponent< props.onKeyUpCapture && props.onKeyUpCapture(event); }; + // [Windows + const childrenWithImportantForAccessibility = children => { + return React.Children.map(children, child => { + if (React.isValidElement(child)) { + if (child.props.children) { + return React.cloneElement(child, { + accessible: false, + children: childrenWithImportantForAccessibility( + child.props.children, + ), + }); + } else { + return React.cloneElement(child, {accessible: false}); + } + } + return child; + }); + }; + // Windows] + return ( // [Windows // In core this is a TextAncestor.Provider value={false} See @@ -94,6 +114,18 @@ const View: React.AbstractComponent< onKeyDownCapture={_keyDownCapture} onKeyUp={_keyUp} onKeyUpCapture={_keyUpCapture} + // [Windows + accessible={ + props.importantForAccessibility === 'no-hide-descendants' + ? false + : props.accessible + } + children={ + props.importantForAccessibility === 'no-hide-descendants' + ? childrenWithImportantForAccessibility(props.children) + : props.children + } + // Windows] /> ); }} diff --git a/vnext/src/Libraries/Components/View/View.windows.js b/vnext/src/Libraries/Components/View/View.windows.js index b9050da9042..0c5cd0b52cf 100644 --- a/vnext/src/Libraries/Components/View/View.windows.js +++ b/vnext/src/Libraries/Components/View/View.windows.js @@ -75,6 +75,26 @@ const View: React.AbstractComponent< props.onKeyUpCapture && props.onKeyUpCapture(event); }; + // [Windows + const childrenWithImportantForAccessibility = children => { + return React.Children.map(children, child => { + if (React.isValidElement(child)) { + if (child.props.children) { + return React.cloneElement(child, { + accessible: false, + children: childrenWithImportantForAccessibility( + child.props.children, + ), + }); + } else { + return React.cloneElement(child, {accessible: false}); + } + } + return child; + }); + }; + // Windows] + return ( // [Windows // In core this is a TextAncestor.Provider value={false} See @@ -94,6 +114,18 @@ const View: React.AbstractComponent< onKeyDownCapture={_keyDownCapture} onKeyUp={_keyUp} onKeyUpCapture={_keyUpCapture} + // [Windows + accessible={ + props.importantForAccessibility === 'no-hide-descendants' + ? false + : props.accessible + } + children={ + props.importantForAccessibility === 'no-hide-descendants' + ? childrenWithImportantForAccessibility(props.children) + : props.children + } + // Windows] /> ); }} From 3689ae26d0d2fe2345921e04029ebcb4df6a854d Mon Sep 17 00:00:00 2001 From: TatianaKapos Date: Tue, 19 Jul 2022 11:13:45 -0700 Subject: [PATCH 2/3] Change files --- ...-native-win32-66e95e8b-c77f-4122-bcbb-fcb1e6ce5077.json | 7 +++++++ ...ative-windows-93fc478e-4970-43db-9342-1f0e9aa42483.json | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 change/@office-iss-react-native-win32-66e95e8b-c77f-4122-bcbb-fcb1e6ce5077.json create mode 100644 change/react-native-windows-93fc478e-4970-43db-9342-1f0e9aa42483.json diff --git a/change/@office-iss-react-native-win32-66e95e8b-c77f-4122-bcbb-fcb1e6ce5077.json b/change/@office-iss-react-native-win32-66e95e8b-c77f-4122-bcbb-fcb1e6ce5077.json new file mode 100644 index 00000000000..4a1763d9be8 --- /dev/null +++ b/change/@office-iss-react-native-win32-66e95e8b-c77f-4122-bcbb-fcb1e6ce5077.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "Implement no-hide-accessibility", + "packageName": "@office-iss/react-native-win32", + "email": "tatianakapos@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/react-native-windows-93fc478e-4970-43db-9342-1f0e9aa42483.json b/change/react-native-windows-93fc478e-4970-43db-9342-1f0e9aa42483.json new file mode 100644 index 00000000000..d60b7fe2145 --- /dev/null +++ b/change/react-native-windows-93fc478e-4970-43db-9342-1f0e9aa42483.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "Implement no-hide-accessibility", + "packageName": "react-native-windows", + "email": "tatianakapos@microsoft.com", + "dependentChangeType": "patch" +} From 116c35d3d7ebe4f578de6f13ab634956b229928f Mon Sep 17 00:00:00 2001 From: TatianaKapos Date: Tue, 19 Jul 2022 13:26:09 -0700 Subject: [PATCH 3/3] yarn lint --- .../Libraries/Components/View/View.windows.js | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/vnext/src/Libraries/Components/View/View.windows.js b/vnext/src/Libraries/Components/View/View.windows.js index 0c5cd0b52cf..aa093c8c4ca 100644 --- a/vnext/src/Libraries/Components/View/View.windows.js +++ b/vnext/src/Libraries/Components/View/View.windows.js @@ -75,25 +75,25 @@ const View: React.AbstractComponent< props.onKeyUpCapture && props.onKeyUpCapture(event); }; - // [Windows - const childrenWithImportantForAccessibility = children => { - return React.Children.map(children, child => { - if (React.isValidElement(child)) { - if (child.props.children) { - return React.cloneElement(child, { - accessible: false, - children: childrenWithImportantForAccessibility( - child.props.children, - ), - }); - } else { - return React.cloneElement(child, {accessible: false}); - } + // [Windows + const childrenWithImportantForAccessibility = children => { + return React.Children.map(children, child => { + if (React.isValidElement(child)) { + if (child.props.children) { + return React.cloneElement(child, { + accessible: false, + children: childrenWithImportantForAccessibility( + child.props.children, + ), + }); + } else { + return React.cloneElement(child, {accessible: false}); } - return child; - }); - }; - // Windows] + } + return child; + }); + }; + // Windows] return ( // [Windows