From d5f31c5c39a7970746c7e756b0628a742fa0cf54 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 3 Oct 2026 13:50:23 +0000 Subject: [PATCH] Fix scrollbar crash when container is shorter than min thumb height coerceIn(10dp..height) throws IllegalArgumentException when the drawn height is below 10dp (e.g. 0 during a sheet animation). Skip drawing at zero height and cap the minimum thumb height at the container height. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CSFYvnepFMHdUqYc3SzXVC --- .../com/greenart7c3/nostrsigner/ui/ScrollableModifier.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/ui/ScrollableModifier.kt b/app/src/main/java/com/greenart7c3/nostrsigner/ui/ScrollableModifier.kt index f0482244..e668865d 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/ui/ScrollableModifier.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/ui/ScrollableModifier.kt @@ -18,13 +18,13 @@ fun Modifier.verticalScrollbar( Modifier.drawWithContent { drawContent() - if (state.maxValue > 0) { + val height = size.height + if (state.maxValue > 0 && height > 0f) { val width = size.width - val height = size.height val scrollFraction = state.value.toFloat() / state.maxValue.toFloat() val scrollbarHeight = (height * height / (state.maxValue + height)) - .coerceIn(10.dp.toPx()..height) + .coerceIn(10.dp.toPx().coerceAtMost(height)..height) val scrollableHeight = height - scrollbarHeight val scrollbarY = scrollableHeight * scrollFraction