From 01b19a634502cce209b8ae569c40391c3727d952 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 9 Nov 2015 03:13:09 +0000 Subject: [PATCH] Customize: Fix focus and autofocus on `nav_menu_item` controls. Embed the `nav_menu_item` control not only when the contained `nav_menu` section expands, but also if the control was autofocused (via the `autofocus[control]` query param). Also applies change from [33596] to work-around a broken `:focusable` selector in jQuery UI. See #33258. Fixes #34629. git-svn-id: https://develop.svn.wordpress.org/trunk@35584 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/customize-nav-menus.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/wp-admin/js/customize-nav-menus.js b/src/wp-admin/js/customize-nav-menus.js index 85bc8ee1d1..9db1664b00 100644 --- a/src/wp-admin/js/customize-nav-menus.js +++ b/src/wp-admin/js/customize-nav-menus.js @@ -1012,7 +1012,7 @@ return; } section = api.section( sectionId ); - if ( section && section.expanded() ) { + if ( ( section && section.expanded() ) || api.settings.autofocus.control === control.id ) { control.actuallyEmbed(); } }, @@ -1433,9 +1433,12 @@ * the first input in the control. */ focus: function() { - this.expandControlSection(); - this.expandForm(); - this.container.find( '.menu-item-settings :focusable:first' ).focus(); + var control = this, focusable; + control.expandControlSection(); + control.expandForm(); + // Note that we can't use :focusable due to a jQuery UI issue. See: https://github.com/jquery/jquery-ui/pull/1583 + focusable = control.container.find( '.menu-item-settings' ).find( 'input, select, textarea, button, object, a[href], [tabindex]' ).filter( ':visible' ); + focusable.first().focus(); }, /**