A11Y: improve poll history talkback behavior.

This commit is contained in:
Benoit Marty 2025-06-13 10:22:03 +02:00 committed by Benoit Marty
parent 23cd587e2c
commit 282923840b
2 changed files with 16 additions and 4 deletions

View file

@ -29,6 +29,8 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource 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.text.style.TextAlign
import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
@ -178,7 +180,9 @@ private fun PollHistoryList(
if (pollHistoryItems.isEmpty()) { if (pollHistoryItems.isEmpty()) {
item { item {
Column( Column(
modifier = Modifier.fillParentMaxSize().padding(bottom = 24.dp), modifier = Modifier
.fillParentMaxSize()
.padding(bottom = 24.dp),
verticalArrangement = Arrangement.Center, verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally, horizontalAlignment = Alignment.CenterHorizontally,
) { ) {
@ -191,7 +195,9 @@ private fun PollHistoryList(
text = emptyStringResource, text = emptyStringResource,
style = ElementTheme.typography.fontBodyLgRegular, style = ElementTheme.typography.fontBodyLgRegular,
color = ElementTheme.colors.textSecondary, 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, textAlign = TextAlign.Center,
) )
@ -227,7 +233,10 @@ private fun PollHistoryItemRow(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
) { ) {
Surface( 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), border = BorderStroke(1.dp, ElementTheme.colors.borderInteractiveSecondary),
shape = RoundedCornerShape(size = 12.dp) shape = RoundedCornerShape(size = 12.dp)
) { ) {

View file

@ -131,7 +131,10 @@ class PollHistoryViewTest {
rule.setPollHistoryViewView( rule.setPollHistoryViewView(
state = state, state = state,
) )
rule.onNodeWithText(answer.text).performClick() rule.onNodeWithText(
text = answer.text,
useUnmergedTree = true,
).performClick()
eventsRecorder.assertSingle( eventsRecorder.assertSingle(
PollHistoryEvents.SelectPollAnswer(eventId, answer.id) PollHistoryEvents.SelectPollAnswer(eventId, answer.id)
) )