Uh oh!
There was an error while loading. Please reload this page.
Make TextInput "clear text" button accessible - #17230
Conversation
shergin
commented
Dec 18, 2017
How does this affect the accessibility of UITextView's content? |
haitaoli
commented
Dec 18, 2017
The UITextView is exposed to accessibility interface as a child element. |
shergin
commented
Dec 18, 2017
@haitaoli Ooops, I meant UITextField.
|
shergin
commented
Dec 18, 2017
Thank you for tackling this, BTW! This is really valuable! |
haitaoli
commented
Dec 18, 2017
|
facebook-github-bot
left a comment
There was a problem hiding this comment.
@shergin is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
commented
Dec 19, 2017
I tried to merge this pull request into the Facebook internal repo but some checks failed. To unblock yourself please check the following: Does this pull request pass all open source tests on GitHub? If not please fix those. Does the code still apply cleanly on top of GitHub master? If not can please rebase. In all other cases this means some internal test failed, for example a part of a fb app won't work with this pull request. I've added the Import Failed label to this pull request so it is easy for someone at fb to find the pull request and check what failed. If you don't see anyone comment in a few days feel free to comment mentioning one of the core contributors to the project so they get a notification. |
addfdbc to
df5acceCompareshergin
commented
Jan 29, 2018
@haitaoli Well, actually RCTUITextField does not wrap it, it subclasses UITextField. So, the text input should behave very well in terms of accessibility. And I am afraid that this changes can interfere with built-in logic. 🤔 Why do you/we need to make "clear" button accessible in the first place? |
haitaoli
commented
Jan 29, 2018
@shergin On iOS, an element can either be accessible, or contain accessible children, but not both: https://developer.apple.com/documentation/uikit/accessibility/uiaccessibilitycontainer. If the TextInput has a button, then we want it accessible, because it's a button and people with disabilities will find it useful. In React Native, the |
shergin
commented
Jan 29, 2018
@haitaoli So, how does the current default behaviour of different from default UITextView/UITextField? If it's not, we have to be really really careful because this component is really really important and must be perfect from an accessibility perspective. And it must be not RN specific issue, so we have to try to find how other products address it. I am not an accessible expert, so I don't know for sure, but... do you people with disabilities really need this button? Maybe there is a special gesture for cleaning the text input so they simply don't need a button? |
haitaoli
commented
Jan 29, 2018
@shergin the current behavior of RCTUITextField overrides |
shergin
commented
Feb 4, 2018
Yes, I tested on a real device and in standard apps clear button is accessible. So, if in RN it does not by default, we have to fix it. But first of all, we have to understand why it is happening now. |
haitaoli
commented
Feb 5, 2018
I didn't. But it should be called on any component with |
Seems like it is marked accessible because of the native TextInput component is wrapped with TouchableWithoutFeedback which is accessible by default https://github.com/facebook/react-native/blob/2cf50e8fff0dc3621092cef4ce9ddffcb1a20903/Libraries/Components/Touchable/TouchableWithoutFeedback.js#L188 Maybe this could just be fixed in js land? cc @shergin |
haitaoli
commented
Oct 18, 2018
I don't think there is a workaround on JS side. The native view cannot be set to be accessible without hiding that clear button. |
cpojer
commented
Jan 28, 2019
Seems like this is an RN in open source issue, and @janicduplessis is right that we can probably fix this with a JS only fix. I'm gonna close this PR for now but happy to reopen if I'm wrong. |


Motivation
This PR makes TextInput "clear text" button accessible. UITextField is wrapped inside a RCTUITextField control which has isAccessibleElement set to TRUE. This prevents iOS accessibility interface from enumerating child elements. This change makes the RCTextField not accessible, but allows child elements to be enumerated if the
accessibleprop is set to true.Issue
#16989
Test Plan
Manually tested with RNTester sample app and accessibility explorer.
Release Notes
[IOS] [BUGFIX] [TextInput] - Made "clear text" button accessible