Skip to content
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

Stop accessibility talkback from reading textfields twice #4683

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.editableText
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.input.ImeAction
import com.stripe.android.ui.core.R

Expand Down Expand Up @@ -147,6 +149,7 @@ internal fun TextField(
}
.semantics {
this.contentDescription = contentDescription
this.editableText = AnnotatedString("")
Comment on lines 151 to +152
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like content description should be describing what the field is, like the field requesting your name, and editableText should be the value entered by the user?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talkback already describes what the field is - that's a different property. ContentDescription is how we get talkback to read the contents of the textfield, by each number individually, as 4 2 4 2 instead of 4-thousand-2-hundred-twenty-two. Since we have contentDescription, the editableText is causing it to read the contents twice.

},
keyboardActions = KeyboardActions(
onNext = {
Expand Down