Tolriq
08/27/2025, 6:52 PMTolriq
08/27/2025, 6:53 PM@Composable
fun NestedScrollStateHandler(navigator: BottomSheetNavigator, scrollState: ScrollState?, disableDragToDismiss: Boolean) {
val nestedScrollDisabled by remember(scrollState, disableDragToDismiss) {
derivedStateOf {
disableDragToDismiss || (scrollState?.canScrollBackward == true)
}
}
SideEffect {
navigator.disableNestedScroll(nestedScrollDisabled)
}
DisposableEffect(navigator) {
onDispose { navigator.disableNestedScroll(false) }
}
}
No more works as the nestedScrollDisabled
is no more updated after a change of the canScrollBackward
value.Winson Chiu
08/27/2025, 7:14 PMderivedStateOf
even necessary here? canScrollBackward
is already derived, so you're not saving yourself any updates by re-wrapping it.Tolriq
08/27/2025, 7:37 PMZach Klippenstein (he/him) [MOD]
08/27/2025, 8:23 PMnestedScrollDisabled
inside any kind of snapshot-state-restartable function. If it worked it must have been because NestedScrollStateHandler
just happened to recompose when canScrollBackward
changedZach Klippenstein (he/him) [MOD]
08/27/2025, 8:25 PM@Composable
fun NestedScrollStateHandler(navigator: BottomSheetNavigator, scrollState: ScrollState?, disableDragToDismiss: Boolean) {
LaunchedEffect(scrollState, disableDragToDismiss) {
try {
snapshotFlow {
disableDragToDismiss || (scrollState?.canScrollBackward == true)
}.collect {
navigator.disableNestedScroll(it)
}
} finally {
navigator.disableNestedScroll(false)
}
}
}
Tolriq
08/28/2025, 5:13 AMZach Klippenstein (he/him) [MOD]
08/28/2025, 6:17 AM