fix html editor collapses after toggling sticky fields#4566
Open
Yuukidiv wants to merge 2 commits intoankitects:mainfrom
Open
fix html editor collapses after toggling sticky fields#4566Yuukidiv wants to merge 2 commits intoankitects:mainfrom
Yuukidiv wants to merge 2 commits intoankitects:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 theloadNote()function that does the following:saveSession()saves the current state with the modTime.setNotetypeMeta()sees the new modTime and detect a mismatch, deleting the entire session.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