]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/js/customize-controls.js
WordPress 4.7.1-scripts
[autoinstalls/wordpress.git] / wp-admin / js / customize-controls.js
index 65f5584e8a91f0256a3529616783e27041186118..e6270ee0e6b3f02617e6682780082df12bc82907 100644 (file)
                                } );
 
                                $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' ) ) {
                                        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();
 
                // 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();
                        }
                } );