Skip to content

Commit 55146e0

Browse files
committed
Construct newly-added wide widgets as wide
1 parent 478fb21 commit 55146e0

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

widget-customizer.js

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,10 @@ var WidgetCustomizer = (function ($) {
482482
widget_id: widget_id,
483483
widget_id_base: widget.get( 'id_base' ),
484484
type: customize_control_type,
485-
is_new: ! is_existing_widget
485+
is_new: ! is_existing_widget,
486+
width: widget.get( 'width' ),
487+
height: widget.get( 'height' ),
488+
is_wide: widget.get( 'is_wide' )
486489
},
487490
previewer: control.setting.previewer
488491
} );
@@ -511,27 +514,17 @@ var WidgetCustomizer = (function ($) {
511514
control.setting( sidebar_widgets );
512515
}
513516

514-
var form_autofocus = function () {
515-
var first_inside_input = widget_form_control.container.find( '.widget-inside :input:visible:first' );
516-
if ( first_inside_input.length ) {
517-
first_inside_input.focus();
518-
} else {
519-
widget_form_control.container.find( '.widget-top .widget-action:first' ).focus();
520-
}
521-
};
522-
523517
customize_control.slideDown(function () {
524-
widget_form_control.expandForm();
525-
526518
if ( is_existing_widget ) {
519+
widget_form_control.expandForm();
527520
widget_form_control.updateWidget( widget_form_control.setting(), function ( error ) {
528521
if ( error ) {
529522
throw error;
530523
}
531-
form_autofocus();
524+
widget_form_control.focus();
532525
} );
533526
} else {
534-
form_autofocus();
527+
widget_form_control.focus();
535528
}
536529
});
537530

@@ -862,7 +855,7 @@ var WidgetCustomizer = (function ($) {
862855
var control = this;
863856
control.expandControlSection();
864857
control.expandForm();
865-
control.container.find( ':focusable:first' ).focus();
858+
control.container.find( ':focusable:first' ).focus().trigger( 'click' );
866859
},
867860

868861
/**

0 commit comments

Comments
 (0)