-
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
Make TextInput "clear text" button accessible #17230
Conversation
How does this affect the accessibility of UITextView's content? |
The UITextView is exposed to accessibility interface as a child element. |
@haitaoli Ooops, I meant UITextField.
|
Thank you for tackling this, BTW! This is really valuable! |
|
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.
@shergin is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
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
df5acce
Compare
@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? |
@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 |
@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? |
@shergin the current behavior of RCTUITextField overrides |
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. |
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 react-native/Libraries/Components/TextInput/TextInput.js Lines 825 to 835 in 2cf50e8
which is accessible by default
Maybe this could just be fixed in js land? cc @shergin |
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. |
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
accessible
prop 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