Skip to content

For text input and password input components, use liveRegion on error message #1623

Description

@paulinea

Request from Eliot Jouanjan (WasSDK):

In order to vocalize automatically the error message in text input and password input components, add a liveRegion = LiveRegionMode.Polite to error semantics in OudsTextInputHelperTextErrorMessage:

@Composable
internal fun OudsTextInputHelperTextErrorMessage(
    enabled: Boolean,
    error: OudsError?,
    helperText: String?,
    annotatedHelperText: OudsAnnotatedHelperText?,
    modifier: Modifier = Modifier
) {
    with(OudsTheme.componentsTokens.textInput) {
        val hasError = error != null
        val isHelperTextNullOrBlank = annotatedHelperText?.text.orElse { helperText }.isNullOrBlank()
        if ((!hasError && !isHelperTextNullOrBlank) || (hasError && error.message.isNotBlank())) {
            val textModifier = modifier
                .fillMaxWidth()
                .padding(top = spacePaddingBlockTopHelperText.value)
                .clearAndSetSemantics {
                    if (hasError) {
                        // Add here: liveRegion = LiveRegionMode.Polite
                        error(error.message)
                    } else {
                        contentDescription = helperText.orEmpty()
                    }
                }
            ...
        }
    }
}

Activity

  1. self-assigned this
    on Oct 9, 2026
  2. paulinea commented on Oct 9, 2026

    @paulinea
    MemberAuthor

    The liveRegion is not working correctly, and several issues in the Google tracker mention problems with this functionality.

    Announcing the error message while the user is typing is not recommended, but the following workaround allows the message to be announced at the appropriate time. You only have to add this near your OudsTextInput, OudsPasswordInput, OudsTextArea:

    val view = LocalView.current
    val errorMessage = oudsError?.message
    LaunchedEffect(errorMessage) {
        if (!errorMessage.isNullOrBlank()) {
            @Suppress("DEPRECATION")
            view.announceForAccessibility(errorMessage)
        }
    }

    This code will not be added to OUDS-Android because it can vary depending on the use case but we will add sample code in the demo application for these composants.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions