Search tags filter is dropped after recreation
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
Research direction
The reproduction test is in AnkiDroid/src/test/java/com/ichi2/anki/browser/SearchTagsDialogRecreationTest.kt; start by running its recreation test and tracing how the Tags dialog restores its selection and updates the search filter. Done means confirming the dialog after recreation applies the selected tags, with the regression test passing.
Written by the indexing model from the issue text.
Description
Subject: [EXISTING] Search tags filter is dropped after recreation
Rotating while the search screen's Tags dialog is open, then confirming, leaves the search tags filter unchanged.
⚠️ This issue existed before the PR and should likely be split off into a separate issue.
---
diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/browser/SearchTagsDialogRecreationTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/browser/SearchTagsDialogRecreationTest.kt
new file mode 100644
index 0000000000..8ddfcfc092
--- /dev/null
+++ b/AnkiDroid/src/test/java/com/ichi2/anki/browser/SearchTagsDialogRecreationTest.kt
@@ -0,0 +1,68 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package com.ichi2.anki.browser
+
+import android.content.DialogInterface
+import androidx.appcompat.app.AlertDialog
+import androidx.test.core.app.ActivityScenario
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import com.ichi2.anki.CardBrowser
+import com.ichi2.anki.RobolectricTest
+import com.ichi2.anki.browser.search.StandardSearchFragment
+import com.ichi2.anki.browser.search.requireChildFragment
+import com.ichi2.anki.dialogs.tags.TagsDialog
+import com.ichi2.anki.settings.Prefs
+import com.ichi2.anki.utils.ext.DIALOG_FRAGMENT_TAG
+import org.junit.Test
+import org.junit.runner.RunWith
+import kotlin.test.assertEquals
+import kotlin.test.assertIs
+import kotlin.test.assertNotNull
+
+@RunWith(AndroidJUnit4::class)
+class SearchTagsDialogRecreationTest : RobolectricTest() {
+ @Test
+ fun `search tags dialog updates search filter`() = probe(recreate = false)
+
+ @Test
+ fun `search tags dialog restored after recreation updates search filter`() = probe(recreate = true)
+
+ private fun probe(recreate: Boolean) =
+ runTest {
+ addBasicNote("Tagged").apply {
+ addTag("probe")
+ flush()
+ }
+ Prefs.devUsingCardBrowserSearchView = true
+ try {
+ ActivityScenario.launch(CardBrowser::class.java).use { scenario ->
+ lateinit var browser: CardBrowser
+ scenario.onActivity { browser = it }
+ assertNotNull(browser.cardBrowserFragment.searchView).show()
+ advanceRobolectricLooper()
+ val standard = browser.cardBrowserFragment.requireChildFragment<StandardSearchFragment>(StandardSearchFragment.TAG)
+ standard.viewModel.setTagsFilter(listOf("probe"))
+ advanceRobolectricLooper()
+ standard.binding.tagsChip.performClick()
+ advanceRobolectricLooper()
+ assertIs<TagsDialog>(browser.supportFragmentManager.findFragmentByTag(DIALOG_FRAGMENT_TAG))
+ if (recreate) {
+ scenario.recreate()
+ advanceRobolectricLooper()
+ scenario.onActivity { browser = it }
+ }
+ val vm = browser.cardBrowserFragment.searchViewModel
+ vm.setTagsFilter(emptyList())
+ advanceRobolectricLooper()
+ val dialog = assertIs<TagsDialog>(browser.supportFragmentManager.findFragmentByTag(DIALOG_FRAGMENT_TAG))
+ val button = (dialog.requireDialog() as AlertDialog).getButton(DialogInterface.BUTTON_POSITIVE)
+ advanceRobolectricLooperUntil { button.isEnabled }
+ button.performClick()
+ advanceRobolectricLooper()
+ assertEquals(listOf("probe"), vm.filtersFlow.value.tags)
+ }
+ } finally {
+ Prefs.devUsingCardBrowserSearchView = false
+ }
+ }
+}
- Dominant language
- Kotlin
- Stars
- 12.3k
- Forks
- 3.1k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 383
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ankidroid/Anki-Android
-
Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ankidroid/Anki-Android#23392 ·
Maintainers usually reply within 1 day
-
Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ankidroid/Anki-Android#23390 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
ankidroid/Anki-Android#23385 · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
ankidroid/Anki-Android#23374 ·
Maintainers usually reply within 1 day
-
Selected custom-study tags become unreadablePossibly taken @chesh-ire claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ankidroid/Anki-Android#23352 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
All issues in ankidroid/Anki-Android
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
LeanBitLab/LeanType#864 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 61/100
PixelPlayerHQ/PixelPlayerOSS#249 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
streetcomplete/StreetComplete#7395 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
134130/intellij-mise#552 ·