Skip to content

Commit

Permalink
Disable DragIndication clicks for less than 2 detents
Browse files Browse the repository at this point in the history
Fixes: #21
  • Loading branch information
alexstyl committed Oct 5, 2024
1 parent 1fc7cae commit 1e5eeff
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions core/src/commonMain/kotlin/BottomSheet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -409,20 +409,25 @@ public fun BottomSheetScope.DragIndication(

Box(
modifier = modifier
.onKeyEvent { event ->
return@onKeyEvent if (event.key == Key.Spacebar && event.type == KeyEventType.KeyUp && enabled) {
onIndicationClicked()
true
} else
false
.let {
if (enabled && state.detents.size > 1) {
it.onKeyEvent { event ->
// manually trigger a click as Compose does not trigger clicks on Space press
return@onKeyEvent if (event.key == Key.Spacebar && event.type == KeyEventType.KeyUp) {
onIndicationClicked()
true
} else
false
}
.clickable(
role = Role.Button,
enabled = enabled,
interactionSource = interactionSource,
indication = indication,
onClickLabel = onClickLabel,
onClick = onIndicationClicked
)
} else it
}
.clickable(
role = Role.Button,
enabled = enabled,
interactionSource = interactionSource,
indication = indication,
onClickLabel = onClickLabel,
onClick = onIndicationClicked
)
)
}

0 comments on commit 1e5eeff

Please sign in to comment.