X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/16e7b37c7914d753890c1a05a9335f3b43751eb8..refs/tags/wordpress-4.7.1:/wp-admin/js/customize-controls.js diff --git a/wp-admin/js/customize-controls.js b/wp-admin/js/customize-controls.js index 65f5584e..e6270ee0 100644 --- a/wp-admin/js/customize-controls.js +++ b/wp-admin/js/customize-controls.js @@ -5300,7 +5300,7 @@ } ); $textarea.on( 'keydown', function onKeydown( event ) { - var selectionStart, selectionEnd, value, scroll, tabKeyCode = 9, escKeyCode = 27; + var selectionStart, selectionEnd, value, tabKeyCode = 9, escKeyCode = 27; if ( escKeyCode === event.keyCode ) { if ( ! $textarea.data( 'next-tab-blurs' ) ) { @@ -5325,10 +5325,8 @@ value = textarea.value; if ( selectionStart >= 0 ) { - scroll = $textarea.scrollTop; textarea.value = value.substring( 0, selectionStart ).concat( '\t', value.substring( selectionEnd ) ); $textarea.selectionStart = textarea.selectionEnd = selectionStart + 1; - textarea.scrollTop = scroll; } event.stopPropagation(); @@ -5367,16 +5365,20 @@ // Focus on the control that is associated with the given setting. api.previewer.bind( 'focus-control-for-setting', function( settingId ) { - var matchedControl; + var matchedControls = []; api.control.each( function( control ) { var settingIds = _.pluck( control.settings, 'id' ); if ( -1 !== _.indexOf( settingIds, settingId ) ) { - matchedControl = control; + matchedControls.push( control ); } } ); - if ( matchedControl ) { - matchedControl.focus(); + // Focus on the matched control with the lowest priority (appearing higher). + if ( matchedControls.length ) { + matchedControls.sort( function( a, b ) { + return a.priority() - b.priority(); + } ); + matchedControls[0].focus(); } } );