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": "Implement no-hide-accessibility",
"packageName": "@office-iss/react-native-win32",
"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": "Implement no-hide-accessibility",
"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 @@ -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
Expand All @@ -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]
/>
);
}}
Expand Down
32 changes: 32 additions & 0 deletions vnext/src/Libraries/Components/View/View.windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
/>
);
}}
Expand Down