question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android: Error state change (text inputs)

See original GitHub issue

Description

Error text not supported.

Errors for form fields, while they can be displayed visually in many unique ways, need to have a strong association with the problematic field itself for accessibility. Otherwise, any users who can’t visually see the relation of the error to the field won’t necessarily know which field is the problem.

This issue requires #30848 to be implemented first, and may get solved as part of that implementation.

React Native version:

v0.63

Expected Behavior

On focus of a form field with an error, the error will be announced by the screen reader after the field contents. Upon changing a field and putting it into an error state, the error will immediately be announced by the screen reader.

Android Details

On Android, this behavior is dictated by the “error” property of TextView. It can be set with the setError(errorString) method, which will both visually display the error, as well as set up the right properties for accessibility.

https://developer.android.com/reference/android/widget/TextView#setError(java.lang.CharSequence)

On the accessibility side, what is technically happening is that the “error” and “contentInvalid” properties of the AccessibilityNodeInfo is being set, and an accessibility event is being fired when the component goes into this error state. Code pointer for the Android implementation here:

AccessibilityNodeInfo properties: https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/widget/TextView.java;l=11887-11888?q=setError

Accessibility event firing: https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/widget/TextView.java;l=7284?q=setError

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
blavallacommented, Feb 27, 2021

@kacieb , just a heads up as it looks like you’re working on #30848. This can likely be solved as part of that task (at least on Android), as this behavior should work automatically if you set the error prop on the TextView class.

For iOS this may require making a custom VoiceOver announcement when we get into an error state, and will likely require setting the error text in something like the AccessibilityValue to get it to read it upon focus of the input.

cc @gioneill for iOS specifics

0reactions
fabriziobertoglio1987commented, Jun 24, 2022

I moved PR https://github.com/facebook/react-native/pull/33468 Ready for Review. I remain available for any improvement. Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Show Error on the tip of the Edit Text Android - Stack Overflow
You can show error as PopUp of EditText if (editText.getText().toString().trim().equalsIgnoreCase("")) { editText.setError("This field can ...
Read more >
Implement Form Validation (Error to EditText) in Android
When the data filled in the text filed is wrong -> // this gives error message to particular text field // which contains...
Read more >
Text in Compose - Jetpack - Android Developers
Text is a central piece of any UI, and Jetpack Compose makes it easier to display or write ... when the TextField state...
Read more >
Errors - Patterns - Material Design
Text field input. Helper text may be included before, during, or after a user interacts with each field on a form. Show error...
Read more >
Working with the EditText | CodePath Android Cliffnotes
Here we use the addTextChangedListener to watch as the value changes to determine when to display the error message or revert to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found