Skip to content

fix html editor collapses after toggling sticky fields#4566

Open
Yuukidiv wants to merge 2 commits intoankitects:mainfrom
Yuukidiv:fix-html-editor-collapses-after-toggling
Open

fix html editor collapses after toggling sticky fields#4566
Yuukidiv wants to merge 2 commits intoankitects:mainfrom
Yuukidiv:fix-html-editor-collapses-after-toggling

Conversation

@Yuukidiv
Copy link
Contributor

Problem:
When the HTML editor is active on a field in the Add Cards dialog, toggling the pin/sticky on any field and then adding a note (Ctrl+Enter) causes all active HTML editor fields to collapse unexpectedly.
The editor saves the UI state inside a session object. When the sticky field is toggled, update_notetype_legacy() is called and the notetype's modTime is changed. When we add the new card we call the loadNote() function that does the following:

  1. saveSession() saves the current state with the modTime.
  2. setNotetypeMeta() sees the new modTime and detect a mismatch, deleting the entire session.
  3. setPlainTexts() finds no saved sessions and returns the defaults.

Solution:
My solution revolves around changing how we check if the session is changed or not.
I removed the modTime comparison in setNotetypeMeta(). The check not only causes the fallback of the html after toggling the sticky but also when changing fields names or font changes.
I added a field count check inside setPlainTexts() so now the saved session is discarded only if the number of fields changes.

So now the modTime is used for the syncing in the backend but not for the frontend UI.
I also thought about maybe a solution while still using the modTime as updating the saved modTime in saveSession() instead of removing the check, but this would cause a call from the backend instead of using the cached value, adding complexity to the code.

Fix: #4468

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTML editor collapses after toggling sticky fields and adding a new note

1 participant