Repository navigation
fix(text-input): expose an empty labelled TextInput to screen readers - #5199
Open
datsiuk-ck wants to merge 1 commit into
Open
datsiuk-ck wants to merge 1 commit into
datsiuk-ck wants to merge 1 commit into
Conversation
While the label rested, the input's wrapper had opacity 0, and iOS and
Android leave views with opacity 0 out of the accessibility tree: an empty,
unfocused labelled field was hidden from screen readers. The input now keeps
full opacity while the label rests and fades in once the label floats. The
style always applies, so a field whose label is removed no longer keeps a
stale opacity of 0 (placeholder and text stayed invisible).
While the label rests, the placeholder is now empty instead of ' ':
TalkBack read the blank aloud ("Space, edit box") instead of the label.
iOS multiline fields keep ' ' (react-native#31573).
Fixes callstack#5197
|
Found potential problems with the pull request:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
An empty, unfocused
TextInputwith alabelwas missing from the accessibility tree on iOS and Android, so screen readers skipped it until someone focused it. Every untouched form started in this state. The input's wrapper took the label's float opacity, which is 0 while the label rests, and both platforms drop views with opacity 0 from accessibility.This PR:
''instead of' '. Once the field was reachable, TalkBack announced it as "Space, edit box" instead of its label. iOS multiline fields keep' '(TextInput placeholder remains empty when multiline is true and the placeholder is set after certain timeout react/react-native#31573).Related issue
Fixes #5197
Screenshots / Videos
Screen readers for unfocused text input
Label removed after the field was focused once, then typing "hello":
Test plan
<TextInput label="Email" supportingText="We never share it" placeholder="you@example.com" value={email} onChangeText={setEmail} />and leave it empty.multilinefield.label, focus and type. The placeholder and the typed text show.