You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I just discovered another interaction edge case between ScrollArea and PullToRefreshBox.
In a nutshell, if the list fits on the screen, meaning there there is nothing to scroll, the pull-to-refresh animation cannot be triggered.
Here is a minimal reproduction, which is broken unless you initialise itemCount to any value that makes the list overflow the screen. Adding overscrollEffect = null to the ScrollArea also fixes the issue, but then we still lose the animation + it would require additional checks to know if we're overflowing, which isn't ideal.
@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
@Preview
@Composable
fun Preview() {
var itemCount by remember { mutableIntStateOf(5) }
var isRefreshing by remember { mutableStateOf(false) }
val pullToRefreshState = rememberPullToRefreshState()
val coroutineScope = rememberCoroutineScope()
val onRefresh: () -> Unit = {
isRefreshing = true
coroutineScope.launch {
delay(1500)
itemCount += 5
isRefreshing = false
}
}
Scaffold {
PullToRefreshBox(
modifier = Modifier.padding(it).fillMaxSize(),
state = pullToRefreshState,
isRefreshing = isRefreshing,
onRefresh = onRefresh,
) {
val listState = rememberLazyListState()
ScrollArea(
state = rememberScrollAreaState(listState),
overscrollEffectSides = listOf(OverscrollSides.Bottom),
) {
LazyColumn(Modifier.fillMaxSize(), state = listState) {
items(itemCount) { ListItem({ Text(text = "Item ${itemCount - it}") }) }
}
VerticalScrollbar(
Modifier
.fillMaxHeight()
.align(Alignment.TopEnd)) {
Thumb(Modifier.background(Color.Red))
}
}
}
}
}
The text was updated successfully, but these errors were encountered:
Hi! I just discovered another interaction edge case between
ScrollArea
andPullToRefreshBox
.In a nutshell, if the list fits on the screen, meaning there there is nothing to scroll, the pull-to-refresh animation cannot be triggered.
Here is a minimal reproduction, which is broken unless you initialise
itemCount
to any value that makes the list overflow the screen. AddingoverscrollEffect = null
to theScrollArea
also fixes the issue, but then we still lose the animation + it would require additional checks to know if we're overflowing, which isn't ideal.The text was updated successfully, but these errors were encountered: