You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Freeform: Unrecoverable error if embed present #4125
Opening a classic post containing an embed with Gutenberg leads to a broken Freeform block.
Steps to Reproduce (for bugs)
Start a new post with the classic editor.
Insert a paragraph of text, then add a line break.
Paste an embeddable URL, e.g. https://wordpress.tv/2017/12/04/matt-mullenweg-state-of-the-word-2017/ or https://www.youtube.com/watch?v=e-QFj59PON4. An embed should correctly appear.
Add a new paragraph beneath it.
Save the post, as draft or published.
Open the post with Gutenberg.
Expected Behavior
The original post should appear, looking more or less the same, contained in a Freeform block.
Current Behavior
No content appears, and a TypeError is logged:
TypeError: self.editor.iframeElement is undefined in mce-view.js:866:5
Possible Solution
History bisection suggests this isn't a recent regression — has it always been around? Error originates in Freeform > OldEditor > wp.oldEditor > TinyMCE. Not clear yet if error lies only in TinyMCE or in the interaction with OldEditor.
Further debugging shows that regular blocks still work and that the error is properly contained inside the Freeform block, even though the BlockCrashWarning isn't always shown:
Note that this change in core fixes the issue for me:
diff --git a/wp-includes/js/mce-view.js b/wp-includes/js/mce-view.js
index f5aa2337ea..12bbdd1d4b 100644
--- a/wp-includes/js/mce-view.js+++ b/wp-includes/js/mce-view.js@@ -862,7 +862,7 @@
}
// Obtain the target width for the embed.
- if ( self.editor ) {+ if ( self.editor && self.editor.iframeElement ) {
maxwidth = self.editor.iframeElement.clientWidth - 20; // Minus the sum of horizontal margins and borders.
}
Activity
mcsf commentedon Dec 21, 2017
Note that this change in core fixes the issue for me:
mcsf commentedon Dec 21, 2017
Hack in Gutenberg instead:
mcsf commentedon Dec 21, 2017
This was fixed in core 8 days ago:
Closing this issue. :)