Hello! I am having an accessibility issue. I have ...
# compose
l
Hello! I am having an accessibility issue. I have a bottom sheet with content beneath it. If a user clicks a spot on the bottom sheet where their aren’t clickable components the focus is dispatched to the content beneath it. how can I avoid that?
Imagine I have a component like this:
Copy code
Box {
    Content()
    BottomSheet(
        modifier = Modifier
            .swipeable( ... ),
    )
}
I tried a few different things with the
semantics
,
focusable
, and
focusProperties
Modifier
s to no avail.
e
what BottomSheet is that? Compose has BottomSheetScaffold and ModalBottomSheetLayout
e
I believe that's somewhat opposite to what OP wants - it dismisses the sheet, instead of preventing clicks from passing through it
that is handled by Surface, which the material bottom sheets already use internally. so we need to know which bottom sheet Lucas is using, if it's not one of those…
a
Sorry I misread the message. So do you mean normal clicks or clicks in screen reader mode (because you mentioned "accessibility")? If it's the former, yeah, a
Surface
or a
Modifier.pointerInput(Unit) {}
should work.
l
Sorry, I guess I wasn’t clear. In this case
BottomSheet
is a custom composable.
I tried the
Modifier.pointerInput(Unit) {}
but focus was still passed through. I will try
Surface
The touches are being dispatched right through the
Surface
as well.
e
sounds more like something is wrong with your custom layout drawing on top but not taking events first
l
It can be reproduced here:
Copy code
@Composable
private fun AccessibilityExample() {
    val markerStateSydney = remember { MarkerState(position = LatLng(-34.0, 151.0)) }
    val markerStateTokyo = remember { MarkerState(position = LatLng(35.66, 139.6)) }

    BottomSheetScaffold(
        sheetContent = {
            Spacer(
                modifier = Modifier
                    .background(
                        color = Color.Gray,
                        shape = RoundedCornerShape(topStart = 8.dp, topEnd = 8.dp),
                    )
                    .fillMaxWidth()
                    .fillMaxHeight(0.5f)
            )
        },
    ) {
        GoogleMap(
            modifier = Modifier
                .clearAndSetSemantics { invisibleToUser() }
                .focusable(enabled = false)
                .fillMaxSize()
        ) {
            Marker(
                state = markerStateSydney,
                title = "Marker in Sydney",
            )
            Marker(
                state = markerStateTokyo,
                title = "Marker in Tokyo"
            )
        }
    }
}
If you want a full repo let me know
I can push my changes. I have had so many issues with
goolgle-maps-compose
I have a full blown repo just to repro bugs