WordPress.org

Make WordPress Core

Changeset 27757


Ignore:
Timestamp:
03/26/2014 10:55:46 PM (5 years ago)
Author:
ocean90
Message:

Customizer: Improve accessibility.

Prevent the form only from saving when enter is pressed on a select element or an input, which hasn't the button type.

props westonruter, ocean90.
fixes #26633.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/customize-controls.js

    r27540 r27757  
    919919            overlay = body.children('.wp-full-overlay');
    920920
    921         // Prevent the form from saving when enter is pressed.
     921        // Prevent the form from saving when enter is pressed on an input or select element.
    922922        $('#customize-controls').on( 'keydown', function( e ) {
    923             if ( $( e.target ).is('textarea') )
    924                 return;
    925 
    926             if ( 13 === e.which ) // Enter
     923            var isEnter = ( 13 === e.which ),
     924                $el = $( e.target );
     925
     926            if ( isEnter && ( $el.is( 'input:not([type=button])' ) || $el.is( 'select' ) ) ) {
    927927                e.preventDefault();
     928            }
    928929        });
    929930
Note: See TracChangeset for help on using the changeset viewer.