Skip to content

fix: refresh NoteEditor fields after restoring templates to default#20579

Open
qingfeng19491001 wants to merge 3 commits intoankidroid:mainfrom
qingfeng19491001:fix/restore-note-type-default-fields-not-updated-20510
Open

fix: refresh NoteEditor fields after restoring templates to default#20579
qingfeng19491001 wants to merge 3 commits intoankidroid:mainfrom
qingfeng19491001:fix/restore-note-type-default-fields-not-updated-20510

Conversation

@qingfeng19491001
Copy link
Copy Markdown
Contributor

Purpose / Description

Fixes IndexOutOfBoundsException by refreshing NoteEditor fields after a template reset.And ensure the UI matches the new field count in the backend, preventing a crash on save.

Fixes

Approach

  • Added a flag (EXTRA_NOTETYPE_FIELDS_CHANGED) to the result intent when restores a template to default.
  • Updated NoteEditorFragment to catch this flag and trigger a full UI refresh.
  • Forced the editor to redraw all field input boxes to match the new count, avoiding the crash during save.

How Has This Been Tested?

Manually tested the dialog in the app on a physical device:
Device: realme RMX1991
reproduce actions of #20510
before
81eaf083f3888d9ebe02151b4788c243
after
https://github.com/user-attachments/assets/bba850b5-2256-404c-a73f-71deaefb2e60

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • 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

@qingfeng19491001 qingfeng19491001 changed the title Fix: refresh NoteEditor fields after restoring templates to default fix: refresh NoteEditor fields after restoring templates to default Mar 25, 2026
Copy link
Copy Markdown
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test?

This should ideally be handled by handling the opChanges result. Could you diagnose why this didn't cause a refresh?

@qingfeng19491001
Copy link
Copy Markdown
Contributor Author

Could you add a test?

This should ideally be handled by handling the opChanges result. Could you diagnose why this didn't cause a refresh?

No problem.I'll add a test and a cause to description of pr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restoring a note type to default doesn't update the fields

2 participants