From 21f8256a27b507644e4b820762b4e46a145afb35 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Sun, 13 Aug 2017 06:24:28 +0000 Subject: [PATCH] Widgets: Add missing `open` class for expanded widgets in Customizer; utilize `open` class for expansion detection in Text and Media widgets. Fixes #41625. git-svn-id: https://develop.svn.wordpress.org/trunk@41249 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/customize-widgets.js | 2 ++ src/wp-admin/js/widgets/media-widgets.js | 5 ++--- src/wp-admin/js/widgets/text-widgets.js | 5 ++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wp-admin/js/customize-widgets.js b/src/wp-admin/js/customize-widgets.js index ea032c8469..61cb40de98 100644 --- a/src/wp-admin/js/customize-widgets.js +++ b/src/wp-admin/js/customize-widgets.js @@ -1400,6 +1400,7 @@ complete = function() { self.container.removeClass( 'expanding' ); self.container.addClass( 'expanded' ); + $widget.addClass( 'open' ); $toggleBtn.attr( 'aria-expanded', 'true' ); self.container.trigger( 'expanded' ); }; @@ -1433,6 +1434,7 @@ complete = function() { self.container.removeClass( 'collapsing' ); self.container.removeClass( 'expanded' ); + $widget.removeClass( 'open' ); $toggleBtn.attr( 'aria-expanded', 'false' ); self.container.trigger( 'collapsed' ); }; diff --git a/src/wp-admin/js/widgets/media-widgets.js b/src/wp-admin/js/widgets/media-widgets.js index 452a9e38eb..45c0889654 100644 --- a/src/wp-admin/js/widgets/media-widgets.js +++ b/src/wp-admin/js/widgets/media-widgets.js @@ -1030,7 +1030,7 @@ wp.mediaWidgets = ( function( $ ) { * @returns {void} */ component.handleWidgetAdded = function handleWidgetAdded( event, widgetContainer ) { - var fieldContainer, syncContainer, widgetForm, idBase, ControlConstructor, ModelConstructor, modelAttributes, widgetControl, widgetModel, widgetId, widgetInside, animatedCheckDelay = 50, renderWhenAnimationDone; + var fieldContainer, syncContainer, widgetForm, idBase, ControlConstructor, ModelConstructor, modelAttributes, widgetControl, widgetModel, widgetId, animatedCheckDelay = 50, renderWhenAnimationDone; widgetForm = widgetContainer.find( '> .widget-inside > .form, > .widget-inside > form' ); // Note: '.form' appears in the customizer, whereas 'form' on the widgets admin screen. idBase = widgetForm.find( '> .id_base' ).val(); widgetId = widgetForm.find( '> .widget-id' ).val(); @@ -1088,9 +1088,8 @@ wp.mediaWidgets = ( function( $ ) { * This ensures that the container's dimensions are fixed so that ME.js * can initialize with the proper dimensions. */ - widgetInside = widgetContainer.parent(); renderWhenAnimationDone = function() { - if ( widgetInside.is( ':animated' ) ) { + if ( ! widgetContainer.hasClass( 'open' ) ) { setTimeout( renderWhenAnimationDone, animatedCheckDelay ); } else { widgetControl.render(); diff --git a/src/wp-admin/js/widgets/text-widgets.js b/src/wp-admin/js/widgets/text-widgets.js index bb19f2ffb2..3902aeddc0 100644 --- a/src/wp-admin/js/widgets/text-widgets.js +++ b/src/wp-admin/js/widgets/text-widgets.js @@ -354,7 +354,7 @@ wp.textWidgets = ( function( $ ) { * @returns {void} */ component.handleWidgetAdded = function handleWidgetAdded( event, widgetContainer ) { - var widgetForm, idBase, widgetControl, widgetId, animatedCheckDelay = 50, widgetInside, renderWhenAnimationDone, fieldContainer, syncContainer; + var widgetForm, idBase, widgetControl, widgetId, animatedCheckDelay = 50, renderWhenAnimationDone, fieldContainer, syncContainer; widgetForm = widgetContainer.find( '> .widget-inside > .form, > .widget-inside > form' ); // Note: '.form' appears in the customizer, whereas 'form' on the widgets admin screen. idBase = widgetForm.find( '> .id_base' ).val(); @@ -401,9 +401,8 @@ wp.textWidgets = ( function( $ ) { * This ensures that the textarea is visible and an iframe can be embedded * with TinyMCE being able to set contenteditable on it. */ - widgetInside = widgetContainer.parent(); renderWhenAnimationDone = function() { - if ( widgetInside.is( ':animated' ) ) { + if ( ! widgetContainer.hasClass( 'open' ) ) { setTimeout( renderWhenAnimationDone, animatedCheckDelay ); } else { widgetControl.initializeEditor();