Anki-Android icon indicating copy to clipboard operation
Anki-Android copied to clipboard

fix(note-editor): Deck for "new cards: decide by note type"

Open david-allison opened this issue 1 month ago • 5 comments

Purpose / Description

Introduced in 2644a6d3d5b3304df1e1681a4e609af301e17f86

  • decide by note type was broken

Fixes

  • Fixes #19733

Approach

  • Related: #19650

How Has This Been Tested?

  • Using user-provided collection
  • Changed deck
  • Added a new note
  • Exited
  • Entered
  • Previously selected deck was maintained

Checklist

  • [x] You have a descriptive commit message with a short title (first line, max 50 chars).
  • [x] You have commented your code, particularly in hard-to-understand areas
  • [x] You have performed a self-review of your own code
  • [ ] UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • [ ] UI Changes: You have tested your change using the Google Accessibility Scanner

david-allison avatar Dec 10 '25 00:12 david-allison

IMO: too close to the release window to block. Save for a quick 2.23.1

david-allison avatar Dec 10 '25 00:12 david-allison

This one will be cherry-picked and I feel like I understand it but asking for second set of eyes from @lukstbit since they authored the original chunk and a second set of eyes is always good for a cherry pick to a stable release...

mikehardy avatar Dec 10 '25 13:12 mikehardy

I'm fine with this going in, the issue I mentioned existed in the previous(2.23) code as well.

lukstbit avatar Dec 10 '25 19:12 lukstbit

Potential fix:

diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/NoteEditorFragment.kt b/AnkiDroid/src/main/java/com/ichi2/anki/NoteEditorFragment.kt
index a4141bfed8..40ba4fbd02 100644
--- a/AnkiDroid/src/main/java/com/ichi2/anki/NoteEditorFragment.kt
+++ b/AnkiDroid/src/main/java/com/ichi2/anki/NoteEditorFragment.kt
@@ -2788,7 +2788,7 @@ class NoteEditorFragment :
 
         // Update deck
         if (!getColUnsafe.config.getBool(ConfigKey.Bool.ADDING_DEFAULTS_TO_CURRENT_DECK)) {
-            deckId = noteType.did
+            deckId = getColUnsafe.defaultsForAdding().deckId
         }
 
         refreshNoteData(FieldChangeType.changeFieldCount(shouldReplaceNewlines()))

lukstbit avatar Dec 10 '25 19:12 lukstbit

Drafting. Thanks!

I'd like to spend a little more time on correctness/testing before this goes in.

david-allison avatar Dec 10 '25 23:12 david-allison

I have written two tests and applied @lukstbit's test, which fixes the second issue. Thank you for the thorough review!

david-allison avatar Dec 11 '25 15:12 david-allison