Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix accessible prop on TextView #2012

Merged
merged 4 commits into from
Jan 31, 2024
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
5 changes: 4 additions & 1 deletion packages/react-native/Libraries/Components/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,10 @@ class Button extends React.Component<ButtonProps> {
tooltip={tooltip} // [macOS]
touchSoundDisabled={touchSoundDisabled}>
<View style={buttonStyles}>
<Text style={textStyles} disabled={disabled}>
<Text
style={textStyles}
disabled={disabled}
accessible={Platform.OS !== 'macos' /* [macOS] */}>
{formattedTitle}
</Text>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ exports[`<Button /> should be disabled and it should set accessibilityState to d
}
>
<Text
accessible={true}
disabled={true}
style={
Array [
Expand Down Expand Up @@ -119,6 +120,7 @@ exports[`<Button /> should be disabled when disabled is empty and accessibilityS
}
>
<Text
accessible={true}
disabled={true}
style={
Array [
Expand Down Expand Up @@ -189,6 +191,7 @@ exports[`<Button /> should be disabled when disabled={true} and accessibilitySta
}
>
<Text
accessible={true}
disabled={true}
style={
Array [
Expand Down Expand Up @@ -259,6 +262,7 @@ exports[`<Button /> should be set importantForAccessibility={no-hide-descendants
}
>
<Text
accessible={true}
style={
Array [
Object {
Expand Down Expand Up @@ -325,6 +329,7 @@ exports[`<Button /> should be set importantForAccessibility={no-hide-descendants
}
>
<Text
accessible={true}
style={
Array [
Object {
Expand Down Expand Up @@ -390,6 +395,7 @@ exports[`<Button /> should not be disabled when disabled={false} and accessibili
}
>
<Text
accessible={true}
disabled={false}
style={
Array [
Expand Down Expand Up @@ -456,6 +462,7 @@ exports[`<Button /> should not be disabled when disabled={false} and accessibili
}
>
<Text
accessible={true}
disabled={false}
style={
Array [
Expand Down Expand Up @@ -523,6 +530,7 @@ exports[`<Button /> should overwrite accessibilityState with value of disabled p
}
>
<Text
accessible={true}
disabled={true}
style={
Array [
Expand Down Expand Up @@ -592,6 +600,7 @@ exports[`<Button /> should render as expected 1`] = `
}
>
<Text
accessible={true}
style={
Array [
Object {
Expand Down
7 changes: 7 additions & 0 deletions packages/react-native/Libraries/Text/Text/RCTTextView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ - (instancetype)initWithFrame:(CGRect)frame
return self;
}

#if TARGET_OS_OSX // [macOS
- (RCTPlatformView *)reactAccessibilityElement
{
return _textView;
}
#endif // macOS]

#if DEBUG // [macOS] description is a debug-only feature
- (NSString *)description
{
Expand Down
Loading