From c6c9eae522bf7b6afd57257e28378d2b1db5457d Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Wed, 26 Mar 2014 22:55:46 +0000 Subject: [PATCH] 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 --- src/wp-admin/js/customize-controls.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index 64109a2b88..39edc8b411 100644 --- a/src/wp-admin/js/customize-controls.js +++ b/src/wp-admin/js/customize-controls.js @@ -918,13 +918,14 @@ body = $( document.body ), 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 ) { - if ( $( e.target ).is('textarea') ) - return; + var isEnter = ( 13 === e.which ), + $el = $( e.target ); - if ( 13 === e.which ) // Enter + if ( isEnter && ( $el.is( 'input:not([type=button])' ) || $el.is( 'select' ) ) ) { e.preventDefault(); + } }); // Initialize Previewer