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.

git-svn-id: https://develop.svn.wordpress.org/trunk@27757 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90) 2014-03-26 22:55:46 +00:00
parent c55cdfa85d
commit c6c9eae522
1 changed files with 5 additions and 4 deletions

View File

@ -918,13 +918,14 @@
body = $( document.body ), body = $( document.body ),
overlay = body.children('.wp-full-overlay'); overlay = body.children('.wp-full-overlay');
// Prevent the form from saving when enter is pressed. // Prevent the form from saving when enter is pressed on an input or select element.
$('#customize-controls').on( 'keydown', function( e ) { $('#customize-controls').on( 'keydown', function( e ) {
if ( $( e.target ).is('textarea') ) var isEnter = ( 13 === e.which ),
return; $el = $( e.target );
if ( 13 === e.which ) // Enter if ( isEnter && ( $el.is( 'input:not([type=button])' ) || $el.is( 'select' ) ) ) {
e.preventDefault(); e.preventDefault();
}
}); });
// Initialize Previewer // Initialize Previewer