WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#31295 closed defect (bug) (fixed)

Programmatically changing sidebars_widgets Customizer settings causes unexpected widget control focus

Reported by: westonruter Owned by: ocean90
Milestone: 4.2 Priority: normal
Severity: normal Version: 4.1
Component: Customize Keywords: has-patch
Focuses: javascript Cc:

Description

Normally when adding a new widget to a sidebar in the Customizer, the expected UI is for the newly-added widget to receive keyboard focus for editing. However, this is currently happening regardless of whether or not a sidebars_widgets setting was updated via this Add Widget UI interaction, or if it was done programmatically. If, in the latter case, a widget was added to a sidebars_widgets[...] setting, it is not expected that this should cause the control to be focused. Any such focus should be done programmatically instead.

To reproduce the issue, enter the following commands in the JS console while in the Customizer with a populated sidebar-1:

wp.customize.section( 'sidebar-widgets-sidebar-1' ).expand()
var widgetIds = wp.customize( 'sidebars_widgets[sidebar-1]' ).get().slice( 0 );
var firstWidgetId = widgetIds.shift();
wp.customize('sidebars_widgets[sidebar-1]').set( widgetIds );

var newWidgetIds = widgetIds.slice( 0 );
newWidgetIds.push( firstWidgetId );
wp.customize('sidebars_widgets[sidebar-1]').set( newWidgetIds );

Attachments (1)

31295.diff (1.1 KB) - added by westonruter 6 years ago.
https://github.com/xwp/wordpress-develop/pull/70

Download all attachments as: .zip

Change History (3)

#1 @westonruter
6 years ago

  • Keywords has-patch added

#2 @ocean90
6 years ago

  • Owner set to ocean90
  • Resolution set to fixed
  • Status changed from new to closed

In 31428:

Customizer: Don't focus new widgets if they are added programmatically.

props westonruter.
fixes #31295.

Note: See TracTickets for help on using tickets.