material-components / material-components/material-components-android
[TextInputEditText] [TextInputLayout] TalkBack issue when error is displayed
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 17.4k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
**Description:** I have a TalkBack issue with TextInputLayout + TextInputEditText combo. I have a form type of screen that presents a number of editable fields (some mandatory, some optional) to the user. I’m performing a form validation when the user selects Save action. If the form is not properly filled (e.g. mandatory info missing, field input is too short or otherwise does not fill the requirements) I set the error message on the TextInputLayout and make requestFocus() -call on the first text field that has an error. The TalkBack will then correctly read the error message but the accessibility focus (green box) stays in the element (ToolBar action) that fired the form validation.
To tackle this issue I started experimenting if I could move the accessibility focus on the text field by making this call:
`inputEdit.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED)`
If I make the call on the TextInputEditText, the behavior will change. Now the accessibility focus will move to the view that has focus and error set but the TalkBack reads the hint text set on the TextInputLayout. If I make the call on the TextInputLayout instead, it doesn’t do anything i.e. TalkBack will read the error message but the accessibility focus is not moved.
**Expected behavior:** There should an easy way (preferably default behavior) to move the accessibility focus and make the TalkBack to read an error message set on the TextInputLayout when the view gets the focus.
**Source code:**
`
`
**Android API version:** Android API 28
**Material Library version:** 1.3.0
**Device:** Sony Xperia (G8441)
To help us triage faster, please check to make sure you are using the [latest version](https://github.com/material-components/material-components-android/releases) of the library.
We also happily accept [pull requests](https://github.com/material-components/material-components-android/pulls).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the TalkBack behavior from the provided TextInputLayout and TextInputEditText XML on Android API 28, focusing on focus and error announcements. Trace the accessibility behavior of TextInputLayout and TextInputEditText; done means the accessibility focus moves to the errored field and TalkBack reads the TextInputLayout error when focus is requested.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android
- Domain
- accessibility, mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100