From ea44136764f1fba84b6cf12525b0f9892f253314 Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Wed, 11 Feb 2015 23:31:20 +0000 Subject: [PATCH] Customizer: Don't focus new widgets if they are added programmatically. props westonruter. fixes #31295. git-svn-id: https://develop.svn.wordpress.org/trunk@31428 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/customize-widgets.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/wp-admin/js/customize-widgets.js b/src/wp-admin/js/customize-widgets.js index 600f8b7882..2472f1e2fc 100644 --- a/src/wp-admin/js/customize-widgets.js +++ b/src/wp-admin/js/customize-widgets.js @@ -250,7 +250,7 @@ // Adds a selected widget to the sidebar submit: function( widgetTpl ) { - var widgetId, widget; + var widgetId, widget, widgetFormControl; if ( ! widgetTpl ) { widgetTpl = this.selected; @@ -268,7 +268,10 @@ return; } - this.currentSidebarControl.addWidget( widget.get( 'id_base' ) ); + widgetFormControl = this.currentSidebarControl.addWidget( widget.get( 'id_base' ) ); + if ( widgetFormControl ) { + widgetFormControl.focus(); + } this.close(); }, @@ -1844,18 +1847,14 @@ controlContainer.slideDown( function() { if ( isExistingWidget ) { - widgetFormControl.expand(); widgetFormControl.updateWidget( { instance: widgetFormControl.setting(), complete: function( error ) { if ( error ) { throw error; } - widgetFormControl.focus(); } } ); - } else { - widgetFormControl.focus(); } } );