BUGFIX: 3839 ckeditor only save changes if (really) dirty #3846
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.
Resolves: #3839
Alternative fix for: #3832
What I did
The
onChange
callback is since also fired after defocusing an editor (#3751). A followup introduced a check to compare the contents if the change is indeed new (#3833).The comparison is fragile and not always in the users intention. (#3839)
This pr reverts the check and introduces a more stable isDirty handling.
How I did it
While i researched the isDirty tracking i stumbled upon ckeditor/ckeditor5#996 (comment), naively i did a little tunnel through space and had to frizzle a lot with state handling.
But when trying to solve the problem of deduplicating the debounce after the focus was lost i stumbled upon
.flush
which is EXACTLY what we need here. No further logic needed. And it guarantees a stable, simple to read and best possible behaviour.How to verify it