Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#31295 closed defect (bug) (fixed)

Programmatically changing sidebars_widgets Customizer settings causes unexpected widget control focus

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

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 12 years ago.
https://github.com/xwp/wordpress-develop/pull/70

Download all attachments as: .zip

Change History (3)

#1 @westonruter
12 years ago

  • Keywords has-patch added

#2 @ocean90
12 years ago

  • Owner set to ocean90
  • Resolutionfixed
  • Status newclosed

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.