Tag edits are lost after the browser is recreated
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start with AnkiDroid/src/test/java/com/ichi2/anki/browser/EditTagsDialogRecreationTest.kt, which reproduces the failure by recreating the browser while the Edit tags dialog is open. Trace how TagsDialog restores its state and applies tag edits after recreation. Done means the regression test passes and the selected notes receive the added tag after confirming the restored dialog.
Written by the indexing model from the issue text.
Description
Subject: [EXISTING] Tag edits are lost after the browser is recreated
Rotating the browser while Edit tags is open, then confirming, silently leaves the selected notes' tags 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/EditTagsDialogRecreationTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/browser/EditTagsDialogRecreationTest.kt
new file mode 100644
index 0000000000..98ef0eeb0f
--- /dev/null
+++ b/AnkiDroid/src/test/java/com/ichi2/anki/browser/EditTagsDialogRecreationTest.kt
@@ -0,0 +1,79 @@
+// 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.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 EditTagsDialogRecreationTest : RobolectricTest() {
+ @Test
+ fun `edit tags dialog edits the note`() = editTags(recreate = false)
+
+ @Test
+ fun `edit tags dialog restored after recreation edits the note`() = editTags(recreate = true)
+
+ private fun editTags(recreate: Boolean) =
+ runTest {
+ val note =
+ 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 }
+ browser.viewModel.searchJob?.join()
+ advanceRobolectricLooper()
+ assertNotNull(
+ browser.cardBrowserFragment.childFragmentManager.findFragmentByTag(StandardSearchFragment.TAG),
+ "StandardSearchFragment exists before the search view is opened",
+ )
+ browser.viewModel.selectAll()?.join()
+ advanceRobolectricLooper()
+ browser.cardBrowserFragment.showEditTagsDialog()
+ advanceRobolectricLooperUntil { browser.supportFragmentManager.findFragmentByTag(DIALOG_FRAGMENT_TAG) is TagsDialog }
+ if (recreate) {
+ scenario.recreate()
+ advanceRobolectricLooper()
+ scenario.onActivity { browser = it }
+ }
+ val dialog = assertIs<TagsDialog>(browser.supportFragmentManager.findFragmentByTag(DIALOG_FRAGMENT_TAG))
+ val button = (dialog.requireDialog() as AlertDialog).getButton(DialogInterface.BUTTON_POSITIVE)
+ advanceRobolectricLooperUntil { button.isEnabled }
+ dialog.viewModel.tags.await().apply {
+ add("added")
+ check("added")
+ }
+ button.performClick()
+ advanceRobolectricLooper()
+ browser.viewModel.searchJob?.join()
+ advanceRobolectricLooper()
+ val searchTags = browser.viewModel.searchRequestFlow.value.filters.tags
+ val noteTags = col.getNote(note.id).tags.sorted()
+ assertEquals(
+ "search=[] note=[added, probe]",
+ "search=$searchTags note=$noteTags",
+ "recreate=$recreate rows=${browser.viewModel.rowCount}",
+ )
+ }
+ } 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 Domain changed
Difficulty 1/5 Under an hour Newbie friendliness 79/100
keiyoushi/extensions-source#21174 ·
Maintainers usually reply within 1 day
-
Unified account interface not translated into Simplified ChinesePossibly taken @xuenhua claimed this 3 days ago. Openunconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
thunderbird/thunderbird-android#11936 · 1 comment ·
Maintainers usually reply within 3 days
-
Update toast stylingOpendesign good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
scribe-org/Scribe-Android#778 ·
Maintainers usually reply within 1 day
-
AI Generated CI/CD ⚒️ Flaky-tests 🐦 go 🏃
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
valkey-io/valkey-glide#7772 ·
Maintainers usually reply within 1 day
-
Error Handling Swift
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Automattic/wordpress-rs#1759 ·
Maintainers usually reply within 1 day