From 86698dc3df1c3a5fa4bd52df99d9d69e620b43e1 Mon Sep 17 00:00:00 2001 From: davotoula Date: Fri, 1 May 2026 11:05:10 +0200 Subject: [PATCH] fix(settings): reset drag state before restoring default bottom bar Tapping Restore Default mid-drag would replace `items` with the default list while `draggedItemIndex` still pointed into the old list. If the old index exceeded the new list's lastIndex, the next pointer event indexed `items` out of bounds. Clear drag state before save(). Co-Authored-By: Claude Opus 4.7 (1M context) --- .../ui/screen/loggedIn/settings/BottomBarSettingsScreen.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/BottomBarSettingsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/BottomBarSettingsScreen.kt index 6af0696f2..351a4d2b4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/BottomBarSettingsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/BottomBarSettingsScreen.kt @@ -147,7 +147,11 @@ fun BottomBarSettingsContent(accountViewModel: AccountViewModel) { horizontalArrangement = Arrangement.End, ) { TextButton( - onClick = { save(initialRows(DefaultBottomBarItems)) }, + onClick = { + draggedItemIndex = -1 + dragOffset = 0f + save(initialRows(DefaultBottomBarItems)) + }, ) { Text(stringRes(R.string.bottom_bar_settings_restore_default)) }