Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b9d023ec authored by Fabián Kozynski's avatar Fabián Kozynski
Browse files

Give a role to AvailableTileGridCell without stateDesc

Due to b/418803616, in this case, elements outside of the scrolling
container end up being picked up by talkback, but because the text is
not visible, they are described as "Unlabelled".

Giving them a role makes it so that talkback won't pick them.

Fixes: 413271304
Bug: 418803616
Flag: com.android.systemui.qs_ui_refactor_compose_fragment
Test: manual, using talkback
Change-Id: I1d65cc235b049481e3f0053a16b60042ebb53c78
parent c58f3cdc
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -125,9 +125,11 @@ import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.CustomAccessibilityAction
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.customActions
import androidx.compose.ui.semantics.role
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.stateDescription
import androidx.compose.ui.text.AnnotatedString
@@ -978,7 +980,18 @@ private fun AvailableTileGridCell(
            modifier
                .graphicsLayer { this.alpha = alpha }
                .clickable(enabled = !cell.isCurrent, onClick = onClick, onClickLabel = clickLabel)
                .semantics { stateDescription?.let { this.stateDescription = it } },
                .semantics {
                    if (stateDescription != null) {
                        this.stateDescription = stateDescription
                    } else {
                        // This is needed due to b/418803616. When a clickable element that doesn't
                        // have semantics is slightly out of bounds of a scrollable container, it
                        // will be found by talkback. Because the text is off screen, it will say
                        // "Unlabelled". Instead, give it a role (that is also meaningful when on
                        // screen), and it will be skipped when not visible.
                        this.role = Role.Button
                    }
                },
    ) {
        Box(Modifier.fillMaxWidth().height(TileHeight)) {
            val draggableModifier =