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
This commit is contained in:
Andrea Fercia 2019-04-17 07:17:26 +00:00
parent 0152c18cd2
commit 715a65c561
2 changed files with 8 additions and 6 deletions

View File

@ -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();
});

View File

@ -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();