-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix/2829: force onChange to be updated with TinyMCE content before merge #3450
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3450 +/- ##
=======================================
Coverage 34.64% 34.64%
=======================================
Files 260 260
Lines 6737 6737
Branches 1219 1219
=======================================
Hits 2334 2334
Misses 3717 3717
Partials 686 686
Continue to review full report at Codecov.
|
blocks/editable/index.js
Outdated
onChange() { | ||
if ( ! this.editor.isDirty() ) { | ||
onChange( forced ) { | ||
if ( ! forced && ! this.editor.isDirty() ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a comment to explain that isDirty
should be enough but due to a bug, we need to force sometimes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On talking to the TinyMCE team it's more of a known deficiency needed due to efficiency requirements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the issue for me. A small comment might be good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes it for me. Minor suggestion: renaming forced
to shouldForce
, feel free to ignore.
Ok I will add a comment and rename forced to shouldForce. |
Description
The issue #2829 was caused by the React state not correctly mirroring TinyMCE's state before the merge operation. This was despite the call to onChange directly before calling merge - however onChange was gated on TinyMCE's isDirty and it seems that the isDirty function had not updated to match reality in time (Note: I am told that isDirty functions are really hard to implement efficiently so, while we will tell the TinyMCE team about this, I doubt it is fixable within TinyMCE.). The easiest fix seems to be to force the update of React's state even if the editor doesn't think it has changed which is what I have done here.
How Has This Been Tested?
Manually tested on Firefox and Chrome.
Types of changes
Bug fix.
Checklist: