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

[BUG] Note Editor: 'Discard Changes' is shown if 'Don't Keep Activities' is activated

Open david-allison opened this issue 10 months ago • 13 comments

~~This may be related to https://forums.ankiweb.net/t/new-bug-after-the-update/68026~~

david-allison avatar Jan 09 '26 10:01 david-allison

It's not. Reproduced in 2.22.3-debug

Next steps:

  • git bisect to determine when this was introduced (it may be a longstanding bug)

I thought I'd have time today. I don't. Bisecting should be a good first issue

david-allison avatar Jan 09 '26 10:01 david-allison

Can I work on this?

Fandroid745 avatar Jan 09 '26 11:01 Fandroid745

@Fandroid745 Sure go ahead. Happy coding!

sanjaysargam avatar Jan 09 '26 11:01 sanjaysargam

@Fandroid745 Sure go ahead. Happy coding!

Thanks!

Fandroid745 avatar Jan 09 '26 11:01 Fandroid745

It's not. Reproduced in 2.22.3-debug

Next steps:

  • git bisect to determine when this was introduced (it may be a longstanding bug)

I thought I'd have time today. I don't. Bisecting should be a good first issue

I am unable to reproduce this issue on my phone(Android 15) running 2.23-debug https://github.com/user-attachments/assets/8d5fa920-35dd-46e3-af65-81013f6a5fe2

Fandroid745 avatar Jan 10 '26 06:01 Fandroid745

Interesting, can you bisect to find when it's introduced?

david-allison avatar Jan 10 '26 07:01 david-allison

I will look though the recent commits and check if there are any changes in the card editor logic and post them here.

Fandroid745 avatar Jan 10 '26 08:01 Fandroid745

Could you post the output of git bisect

david-allison avatar Jan 11 '26 06:01 david-allison

Could you post the output of git bisect

@david-allison Could you please tell how to do git bisect if I can't reproduce the actual issue on my phone as I don't know which commit would be good before 2.23-debug. should I try testing on tablet emulator instead?

Fandroid745 avatar Jan 11 '26 06:01 Fandroid745

You can't do git bisect if you can't reproduce the issue

a git bisect necessarily relies on your ability to discriminate between a working commit and a non-working commit via reproduction of the issue. It is not possible to do that if you cannot reproduce.

https://discord.com/channels/368267295601983490/701922522836369498/1459924947483758686

david-allison avatar Jan 12 '26 08:01 david-allison

  • abcfcce8e4b46c5102641d8369bbd7723e922c3d
  • #17597
  • #17521
abcfcce8e4b46c5102641d8369bbd7723e922c3d is the first bad commit
commit abcfcce8e4b46c5102641d8369bbd7723e922c3d
Author: David Allison <[email protected]>
Date:   Sat Dec 14 02:36:54 2024 +0000

    fix(note-editor): restore instance state
    
    Now Note Editor is a fragment, it no longer receives
    `android:viewHierarchyState`. This is now handled by the Activity
    
    But, we did not need to handle this manually.
    Recreating the fields, with the same `id` value restores the text
    
    ----
    
    This fix does not handle the loss of focus for dynamic elements
    
    During testing, this lack of focus coming back from 'Drawing'
    was jarring. In Production this will have minimal impact
    as the user will have lost context by the time the activity is
    restored (a user will not have 'Don't keep activities' on).
    
    Fixes 17521

 AnkiDroid/src/main/java/com/ichi2/anki/noteeditor/FieldState.kt | 65 +++++++++++++++++++----------------------------------------------
 1 file changed, 19 insertions(+), 46 deletions(-)

david-allison avatar Jan 12 '26 09:01 david-allison

Hi 👋
I would like to work on this bug.
Can you please assign it to me?

akkicodes-dev avatar Feb 08 '26 16:02 akkicodes-dev

It is already fixed. You can try other issues

sanjaysargam avatar Feb 09 '26 05:02 sanjaysargam