From 282923840bca4e2c3ce8a4389683175f8f1bc540 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 13 Jun 2025 10:22:03 +0200 Subject: [PATCH] A11Y: improve poll history talkback behavior. --- .../features/poll/impl/history/PollHistoryView.kt | 15 ++++++++++++--- .../poll/impl/history/PollHistoryViewTest.kt | 5 ++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryView.kt b/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryView.kt index d9d639e8a8..1101276577 100644 --- a/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryView.kt +++ b/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryView.kt @@ -29,6 +29,8 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource +import androidx.compose.ui.semantics.isTraversalGroup +import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp @@ -178,7 +180,9 @@ private fun PollHistoryList( if (pollHistoryItems.isEmpty()) { item { Column( - modifier = Modifier.fillParentMaxSize().padding(bottom = 24.dp), + modifier = Modifier + .fillParentMaxSize() + .padding(bottom = 24.dp), verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally, ) { @@ -191,7 +195,9 @@ private fun PollHistoryList( text = emptyStringResource, style = ElementTheme.typography.fontBodyLgRegular, color = ElementTheme.colors.textSecondary, - modifier = Modifier.fillMaxWidth().padding(vertical = 24.dp, horizontal = 16.dp), + modifier = Modifier + .fillMaxWidth() + .padding(vertical = 24.dp, horizontal = 16.dp), textAlign = TextAlign.Center, ) @@ -227,7 +233,10 @@ private fun PollHistoryItemRow( modifier: Modifier = Modifier, ) { Surface( - modifier = modifier, + modifier = modifier.semantics(mergeDescendants = true) { + // Allow the answers to be traversed by Talkback + isTraversalGroup = true + }, border = BorderStroke(1.dp, ElementTheme.colors.borderInteractiveSecondary), shape = RoundedCornerShape(size = 12.dp) ) { diff --git a/features/poll/impl/src/test/kotlin/io/element/android/features/poll/impl/history/PollHistoryViewTest.kt b/features/poll/impl/src/test/kotlin/io/element/android/features/poll/impl/history/PollHistoryViewTest.kt index 3da8d50d49..54df066bbe 100644 --- a/features/poll/impl/src/test/kotlin/io/element/android/features/poll/impl/history/PollHistoryViewTest.kt +++ b/features/poll/impl/src/test/kotlin/io/element/android/features/poll/impl/history/PollHistoryViewTest.kt @@ -131,7 +131,10 @@ class PollHistoryViewTest { rule.setPollHistoryViewView( state = state, ) - rule.onNodeWithText(answer.text).performClick() + rule.onNodeWithText( + text = answer.text, + useUnmergedTree = true, + ).performClick() eventsRecorder.assertSingle( PollHistoryEvents.SelectPollAnswer(eventId, answer.id) )