-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Added support for importantForAccessibility for some components #31296
Changes from 3 commits
c4a4685
94b44c1
a70b59e
9109561
21f3a6b
a105700
7eeafc7
c61ea55
b8747ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,201 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<Picker /> should be set importantForAccessibility={no-hide-descendants} when importantForAccessibility={no}: should deep render when mocked (please verify output manually) 1`] = ` | ||
<View> | ||
<RCTPicker | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see anything about the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kacieb |
||
items={ | ||
Array [ | ||
Object { | ||
"label": "foo", | ||
"textColor": undefined, | ||
"value": "foo", | ||
}, | ||
Object { | ||
"label": "bar", | ||
"textColor": undefined, | ||
"value": "bar", | ||
}, | ||
] | ||
} | ||
onChange={[Function]} | ||
selectedIndex={0} | ||
style={ | ||
Array [ | ||
Object { | ||
"height": 216, | ||
}, | ||
undefined, | ||
] | ||
} | ||
/> | ||
</View> | ||
`; | ||
|
||
exports[`<Picker /> should be set importantForAccessibility={no-hide-descendants} when importantForAccessibility={no}: should deep render when not mocked (please verify output manually) 1`] = ` | ||
<View> | ||
<RCTPicker | ||
items={ | ||
Array [ | ||
Object { | ||
"label": "foo", | ||
"textColor": undefined, | ||
"value": "foo", | ||
}, | ||
Object { | ||
"label": "bar", | ||
"textColor": undefined, | ||
"value": "bar", | ||
}, | ||
] | ||
} | ||
onChange={[Function]} | ||
selectedIndex={0} | ||
style={ | ||
Array [ | ||
Object { | ||
"height": 216, | ||
}, | ||
undefined, | ||
] | ||
} | ||
/> | ||
</View> | ||
`; | ||
|
||
exports[`<Picker /> should be set importantForAccessibility={no-hide-descendants} when importantForAccessibility={no}: should shallow render as <Picker /> when mocked 1`] = ` | ||
<Picker | ||
importantForAccessibility="no" | ||
mode="dialog" | ||
onValueChange={[MockFunction]} | ||
selectedValue="foo" | ||
> | ||
<PickerItem | ||
label="foo" | ||
value="foo" | ||
/> | ||
<PickerItem | ||
label="bar" | ||
value="bar" | ||
/> | ||
</Picker> | ||
`; | ||
|
||
exports[`<Picker /> should be set importantForAccessibility={no-hide-descendants} when importantForAccessibility={no}: should shallow render as <Picker /> when not mocked 1`] = ` | ||
<Picker | ||
importantForAccessibility="no" | ||
mode="dialog" | ||
onValueChange={[MockFunction]} | ||
selectedValue="foo" | ||
> | ||
<PickerItem | ||
label="foo" | ||
value="foo" | ||
/> | ||
<PickerItem | ||
label="bar" | ||
value="bar" | ||
/> | ||
</Picker> | ||
`; | ||
|
||
exports[`<Picker /> should be set importantForAccessibility={no-hide-descendants} when importantForAccessibility={no-hide-descendants}: should deep render when mocked (please verify output manually) 1`] = ` | ||
<View> | ||
<RCTPicker | ||
items={ | ||
Array [ | ||
Object { | ||
"label": "foo", | ||
"textColor": undefined, | ||
"value": "foo", | ||
}, | ||
Object { | ||
"label": "bar", | ||
"textColor": undefined, | ||
"value": "bar", | ||
}, | ||
] | ||
} | ||
onChange={[Function]} | ||
selectedIndex={0} | ||
style={ | ||
Array [ | ||
Object { | ||
"height": 216, | ||
}, | ||
undefined, | ||
] | ||
} | ||
/> | ||
</View> | ||
`; | ||
|
||
exports[`<Picker /> should be set importantForAccessibility={no-hide-descendants} when importantForAccessibility={no-hide-descendants}: should deep render when not mocked (please verify output manually) 1`] = ` | ||
<View> | ||
<RCTPicker | ||
items={ | ||
Array [ | ||
Object { | ||
"label": "foo", | ||
"textColor": undefined, | ||
"value": "foo", | ||
}, | ||
Object { | ||
"label": "bar", | ||
"textColor": undefined, | ||
"value": "bar", | ||
}, | ||
] | ||
} | ||
onChange={[Function]} | ||
selectedIndex={0} | ||
style={ | ||
Array [ | ||
Object { | ||
"height": 216, | ||
}, | ||
undefined, | ||
] | ||
} | ||
/> | ||
</View> | ||
`; | ||
|
||
exports[`<Picker /> should be set importantForAccessibility={no-hide-descendants} when importantForAccessibility={no-hide-descendants}: should shallow render as <Picker /> when mocked 1`] = ` | ||
<Picker | ||
importantForAccessibility="no-hide-descendants" | ||
mode="dialog" | ||
onValueChange={[MockFunction]} | ||
selectedValue="foo" | ||
> | ||
<PickerItem | ||
label="foo" | ||
value="foo" | ||
/> | ||
<PickerItem | ||
label="bar" | ||
value="bar" | ||
/> | ||
</Picker> | ||
`; | ||
|
||
exports[`<Picker /> should be set importantForAccessibility={no-hide-descendants} when importantForAccessibility={no-hide-descendants}: should shallow render as <Picker /> when not mocked 1`] = ` | ||
<Picker | ||
importantForAccessibility="no-hide-descendants" | ||
mode="dialog" | ||
onValueChange={[MockFunction]} | ||
selectedValue="foo" | ||
> | ||
<PickerItem | ||
label="foo" | ||
value="foo" | ||
/> | ||
<PickerItem | ||
label="bar" | ||
value="bar" | ||
/> | ||
</Picker> | ||
`; | ||
|
||
exports[`<Picker /> should render as expected: should deep render when mocked (please verify output manually) 1`] = ` | ||
<View> | ||
<RCTPicker | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! I just wanted to ask why this is needed? What happens if someone specifies "no" without this code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. If set to
no
, the Picker will not focus, but it will focus on the TextView inside that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch @grgr-dkrk !
@kacieb , this is due to the fact that while some components like
<Button>
seem like atomic units, they actually end up rendering a hierarchy of components for example a wrapper<View>
with a<Text>
inside them.By allowing those descendants to become focusable, it sort of breaks the model of these being a single component to consider, so I think forcing no-hide-descendants makes sense here.
The other option is to always render any descendants of these elements with importantForAccessibility="no", so that they can never be focusable on their own. This would have the same end result, but may potentially cause issues when the descendant content is supposed to automatically get moved up to the focusable ancestor to act as a label (which is what Talkback does with unfocusable text elements by default).