From 715a65c56142262b938d6860f840e201b1fe074a Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Wed, 17 Apr 2019 07:17:26 +0000 Subject: [PATCH] Accessibility: Make the Tags meta box better support Input Method Editor (IME) converters. Also, restores the keyboard interaction behavior prior to [41988] by requesting one single Enter key press to add a tag. Props ryanshoover, miyauchi. Fixes #45371. git-svn-id: https://develop.svn.wordpress.org/trunk@45227 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/admin/tags-box.js | 8 ++------ src/js/_enqueues/admin/tags-suggest.js | 6 ++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/js/_enqueues/admin/tags-box.js b/src/js/_enqueues/admin/tags-box.js index d47cbed8a5..c4676f263e 100644 --- a/src/js/_enqueues/admin/tags-box.js +++ b/src/js/_enqueues/admin/tags-box.js @@ -369,7 +369,8 @@ /** * Handles pressing enter on the new tag input field. * - * Prevents submitting the post edit form. + * Prevents submitting the post edit form. Uses `keypress` to take + * into account Input Method Editor (IME) converters. * * @since 2.9.0 * @@ -384,11 +385,6 @@ event.preventDefault(); event.stopPropagation(); } - }).keypress( function( event ) { - if ( 13 == event.which ) { - event.preventDefault(); - event.stopPropagation(); - } }).each( function( i, element ) { $( element ).wpTagsSuggest(); }); diff --git a/src/js/_enqueues/admin/tags-suggest.js b/src/js/_enqueues/admin/tags-suggest.js index 238b8584b1..866d7d0603 100644 --- a/src/js/_enqueues/admin/tags-suggest.js +++ b/src/js/_enqueues/admin/tags-suggest.js @@ -107,6 +107,12 @@ window.wp.a11y.speak( window.tagsSuggestL10n.termSelected, 'assertive' ); event.preventDefault(); } else if ( $.ui.keyCode.ENTER === event.keyCode ) { + // If we're in the edit post Tags meta box, add the tag. + if ( window.tagBox ) { + window.tagBox.userAction = 'add'; + window.tagBox.flushTags( $( this ).closest( '.tagsdiv' ) ); + } + // Do not close Quick Edit / Bulk Edit event.preventDefault(); event.stopPropagation();