From a3fbbed8f4e602f6caf55742e1e6daeb1e11a79c Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 2 Jul 2026 13:16:01 +0200 Subject: [PATCH] A11Y: Improve accessibility of search field. Closes #6389 --- .../features/home/impl/search/RoomListSearchView.kt | 8 ++++++-- libraries/ui-strings/src/main/res/values/localazy.xml | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/search/RoomListSearchView.kt b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/search/RoomListSearchView.kt index 942e924820..f67338ef21 100644 --- a/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/search/RoomListSearchView.kt +++ b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/search/RoomListSearchView.kt @@ -33,6 +33,8 @@ import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.stringResource +import androidx.compose.ui.semantics.contentDescription +import androidx.compose.ui.semantics.semantics import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp import io.element.android.compound.tokens.generated.CompoundIcons @@ -112,10 +114,12 @@ private fun RoomListSearchContent( title = { // The stateSaver will keep the selection state when returning to this UI val focusRequester = remember { FocusRequester() } + val searchLabel = stringResource(CommonStrings.action_search) FilledTextField( modifier = Modifier .fillMaxWidth() - .focusRequester(focusRequester), + .focusRequester(focusRequester) + .semantics { contentDescription = searchLabel }, state = state.query, lineLimits = TextFieldLineLimits.SingleLine, colors = TextFieldDefaults.colors( @@ -132,7 +136,7 @@ private fun RoomListSearchContent( IconButton(onClick = { state.eventSink(RoomListSearchEvent.ClearQuery) }) { Icon( imageVector = CompoundIcons.Close(), - contentDescription = stringResource(CommonStrings.action_cancel) + contentDescription = stringResource(CommonStrings.a11y_clear_search_field) ) } } diff --git a/libraries/ui-strings/src/main/res/values/localazy.xml b/libraries/ui-strings/src/main/res/values/localazy.xml index f477af40d8..4885c38ef3 100644 --- a/libraries/ui-strings/src/main/res/values/localazy.xml +++ b/libraries/ui-strings/src/main/res/values/localazy.xml @@ -4,6 +4,7 @@ "Add reaction: %1$s" "Address" "Avatar" + "Clear search field" "Minimise message text field" "Decrease votes allowed per person" "Increase votes allowed per person"