From da7b514926db217e11fd8e9c71b36e18ba952616 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Tue, 12 Mar 2019 20:13:14 +0000 Subject: [PATCH] TinyMCE: fix editor height when loaded hidden. Props nnikolov, azaozz. Fixes #45461. git-svn-id: https://develop.svn.wordpress.org/trunk@44832 602fd350-edb4-49c9-b593-d223f7449a82 --- .../vendor/tinymce/plugins/wordpress/plugin.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/js/_enqueues/vendor/tinymce/plugins/wordpress/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/wordpress/plugin.js index 3f2cf567ac..95d462d115 100644 --- a/src/js/_enqueues/vendor/tinymce/plugins/wordpress/plugin.js +++ b/src/js/_enqueues/vendor/tinymce/plugins/wordpress/plugin.js @@ -19,7 +19,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { } function toggleToolbars( state ) { - var initial, toolbars, + var initial, toolbars, iframeHeight, pixels = 0, classicBlockToolbar = tinymce.$( '.block-library-classic__toolbar' ); @@ -44,18 +44,24 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { if ( i > 0 ) { if ( state === 'hide' ) { toolbar.hide(); - pixels += 30; + pixels += 34; } else { toolbar.show(); - pixels -= 30; + pixels -= 34; } } }); } // Resize editor iframe, not needed for iOS and inline instances. - if ( pixels && ! tinymce.Env.iOS && editor.iframeElement ) { - DOM.setStyle( editor.iframeElement, 'height', editor.iframeElement.clientHeight + pixels ); + // Don't resize if the editor is in a hidden container. + if ( pixels && ! tinymce.Env.iOS && editor.iframeElement && editor.iframeElement.clientHeight ) { + iframeHeight = editor.iframeElement.clientHeight + pixels; + + // Keep min-height. + if ( iframeHeight > 50 ) { + DOM.setStyle( editor.iframeElement, 'height', iframeHeight ); + } } if ( ! initial ) {