Skip to content

Commit 3cef8c2

Browse files
Announce expanded/collapsed state on the timeline group header (#7226)
* Announce expanded/collapsed state on the timeline group header GroupHeaderView (the accordion-style header used for grouped state events in the timeline) uses toggleable() combined with clearAndSetSemantics { contentDescription = text }. The clearAndSetSemantics block discards the state information that toggleable() would otherwise expose, so TalkBack never announces whether the group is currently expanded or collapsed. Add an explicit stateDescription (two new a11y_state_expanded / a11y_state_collapsed strings in temporary.xml) alongside the existing contentDescription so the expanded/collapsed state is communicated to assistive technology. Internal note: this single-file/single-root-cause fix addresses three separate BITV findings raised in the same accessibility audit against this component's toggle semantics. * Update screenshots --------- Co-authored-by: ElementBot <android@element.io>
1 parent 4a9fd05 commit 3cef8c2

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/group/GroupHeaderView.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ import androidx.compose.ui.Modifier
2626
import androidx.compose.ui.draw.clip
2727
import androidx.compose.ui.draw.rotate
2828
import androidx.compose.ui.graphics.Color
29+
import androidx.compose.ui.res.stringResource
2930
import androidx.compose.ui.semantics.Role
3031
import androidx.compose.ui.semantics.clearAndSetSemantics
3132
import androidx.compose.ui.semantics.contentDescription
33+
import androidx.compose.ui.semantics.stateDescription
3234
import androidx.compose.ui.unit.dp
3335
import io.element.android.compound.theme.ElementTheme
3436
import io.element.android.compound.tokens.generated.CompoundIcons
@@ -37,6 +39,7 @@ import io.element.android.libraries.designsystem.preview.PreviewsDayNight
3739
import io.element.android.libraries.designsystem.theme.components.Icon
3840
import io.element.android.libraries.designsystem.theme.components.Surface
3941
import io.element.android.libraries.designsystem.theme.components.Text
42+
import io.element.android.libraries.ui.strings.CommonStrings
4043

4144
private val CORNER_RADIUS = 8.dp
4245

@@ -52,6 +55,8 @@ fun GroupHeaderView(
5255
val backgroundColor = Color.Transparent
5356
val shape = RoundedCornerShape(CORNER_RADIUS)
5457

58+
val expandedStateDescription = stringResource(CommonStrings.a11y_state_expanded)
59+
val collapsedStateDescription = stringResource(CommonStrings.a11y_state_collapsed)
5560
Box(
5661
modifier = modifier
5762
.fillMaxWidth()
@@ -62,6 +67,7 @@ fun GroupHeaderView(
6267
)
6368
.clearAndSetSemantics {
6469
contentDescription = text
70+
stateDescription = if (isExpanded) expandedStateDescription else collapsedStateDescription
6571
},
6672
contentAlignment = Alignment.Center
6773
) {

libraries/ui-strings/src/main/res/values/temporary.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
<resources>
99
<string name="action_mark_as_read">"Mark as read"</string>
1010
<string name="a11y_jump_to_unread_messages">"Jump to first unread message"</string>
11+
<string name="a11y_state_expanded">"Expanded"</string>
12+
<string name="a11y_state_collapsed">"Collapsed"</string>
1113
<string name="screen_local_network_opt_in_title">Allow access to local network</string>
1214
<string name="screen_local_network_opt_in_subtitle">Your homeserver is on your local network. To connect, Element needs permission to reach other devices on this network.</string>
1315
<string name="a11y_active">Active</string>
Lines changed: 2 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)