git.iko.soy/parseable-android
on master help sign in
Scroll to top of log entry when collapsing below its start (#28)

When a log entry is expanded and taller than the viewport, the user may scroll down within it. Collapsing the entry would leave the viewport at an unexpected position. Now, if the top of the entry is above the viewport when collapsing, the list animates back to show the collapsed card. https://claude.ai/code/session_01MjHpm5Bqvb92fWrh7j31Gg Co-authored-by: Claude <noreply@anthropic.com>

commit6b6d13f812ee7c3d6d00e4efce3a3b95ff097fe5 authoriko <mail@iko.soy> dateThu 19 Feb 2026, 12:34 (7 months ago) parentd8e3b42
1 file changed+16−1
app/src/main/java/com/parseable/android/ui/screens/logviewer/LogViewerScreen.kt+16−1
app/src/main/java/com/parseable/android/ui/screens/logviewer/LogViewerScreen.kt+16−1
@@ -382,7 +382,22 @@ fun LogViewerScreen(
382382 logEntry = logEntry,
383383 isExpanded = expandedLogKey == key,
384384 onClick = {
385− expandedLogKey = if (expandedLogKey == key) null else key
385+ if (expandedLogKey == key) {
386+ // Collapsing: if the top of the entry is scrolled
387+ // above the viewport, jump to it so the user sees
388+ // the collapsed card instead of a random position.
389+ val itemInfo = listState.layoutInfo.visibleItemsInfo
390+ .firstOrNull { it.index == index }
391+ val needsScroll = itemInfo == null || itemInfo.offset < 0
392+ expandedLogKey = null
393+ if (needsScroll) {
394+ scope.launch {
395+ listState.animateScrollToItem(index)
396+ }
397+ }
398+ } else {
399+ expandedLogKey = key
400+ }
386401 },
387402 clipboardManager = clipboard,
388403 onCopied = {