diff --git a/change/@office-iss-react-native-win32-2233ce57-16d8-4600-a96d-ce46a11cadde.json b/change/@office-iss-react-native-win32-2233ce57-16d8-4600-a96d-ce46a11cadde.json new file mode 100644 index 00000000000..7b4095d1ecc --- /dev/null +++ b/change/@office-iss-react-native-win32-2233ce57-16d8-4600-a96d-ce46a11cadde.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "Implement no-hide-accessibility", + "packageName": "@office-iss/react-native-win32", + "email": "34109996+chiaramooney@users.noreply.github.com", + "dependentChangeType": "patch" +} diff --git a/change/react-native-windows-454d3cec-b8c1-4e81-b92a-0b747f9ab9ef.json b/change/react-native-windows-454d3cec-b8c1-4e81-b92a-0b747f9ab9ef.json new file mode 100644 index 00000000000..3c091ef2612 --- /dev/null +++ b/change/react-native-windows-454d3cec-b8c1-4e81-b92a-0b747f9ab9ef.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "Implement no-hide-accessibility", + "packageName": "react-native-windows", + "email": "34109996+chiaramooney@users.noreply.github.com", + "dependentChangeType": "patch" +} 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 d16e6279727..4b083e003c1 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 d16e6279727..4b083e003c1 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] /> ); }}