More restores above the end of the list

Open Beginner friendly
#23,557 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
android, kotlin
Domain
mobile, testing

Research direction

Start with BottomNavigationRestoreTest.kt and the existing restoring More test, then inspect the More tab scroll state restoration path it exercises. Reproduce the case by scrolling to maxValue before process recreation. Done when the restored More tab remains at the same final scroll position and the regression test passes.

Written by the indexing model from the issue text.

Description

Assisted-by: GPT-6.2-Sol xhigh & GPT-6.2-Astra xhigh

[EXISTING] More restores above the end of the list
Subject: [EXISTING] More restores above the end of the list

After process recreation, More reopens above the bottom when the list was previously scrolled all the way down.

---
diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/BottomNavigationRestoreTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/BottomNavigationRestoreTest.kt
index a8b7ba05f7..7bd044caae 100644
--- a/AnkiDroid/src/test/java/com/ichi2/anki/BottomNavigationRestoreTest.kt
+++ b/AnkiDroid/src/test/java/com/ichi2/anki/BottomNavigationRestoreTest.kt
@@ -84,6 +84,22 @@ class BottomNavigationRestoreTest : RobolectricTest() {
             assertThat(restored.moreScrollState.value, equalTo(offset))
         }
 
+    @Test
+    @Config(qualifiers = "w360dp-h500dp")
+    fun `restoring More at the end preserves the final scroll position`() =
+        withBottomNavigation {
+            val controller = launchOn(NavigationItem.MORE)
+            val scroll = controller.get().moreScrollState
+            runBlocking { scroll.scrollTo(scroll.maxValue) }
+            advanceRobolectricLooper()
+            val offset = scroll.value
+            assertThat("The More tab was scrolled to the end", offset, greaterThan(0))
+
+            val restored = restoreAfterProcessDeath(controller)
+            assertShowsTab(restored, NavigationItem.MORE)
+            assertThat(restored.moreScrollState.value, equalTo(offset))
+        }
+
     @Test
     fun `back returns to the deck list after a restore`() =
         forEachTab { tab ->

Originally posted by @david-allison in https://github.com/ankidroid/Anki-Android/pull/23280#pullrequestreview-5982337493

Dominant language
Kotlin
Stars
12.3k
Forks
3.1k
Avg merge
1d 12h
Merged PRs (30d)
377

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ankidroid/Anki-Android

All issues in ankidroid/Anki-Android

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.