Comments: Disable "close on escape" for inline replies when using an IME.
When using an Input Method Editor(IME), pressing escape to perform actions in the IME is common. However, if this was done while replying to a comment, the "close on escape" feature was also triggered which cleared the current textarea and closed it. This change checks if an IME is in use by binding the `compositionstart` event to the reply text box and setting a flag if it's triggered. The "close on escape" feature will now only be triggered if this new flag is not set after typing a reply. Props BettyJJ, sabernhardt, alexstine, konradyoast, audrasjb, rafiahmedd, afercia. Fixes #54548. Built from https://develop.svn.wordpress.org/trunk@52951 git-svn-id: http://core.svn.wordpress.org/trunk@52540 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
df3dae33cc
commit
92a1067f1d
|
@ -1019,7 +1019,8 @@ window.commentReply = {
|
|||
}
|
||||
|
||||
setTimeout(function() {
|
||||
var rtop, rbottom, scrollTop, vp, scrollBottom;
|
||||
var rtop, rbottom, scrollTop, vp, scrollBottom,
|
||||
isComposing = false;
|
||||
|
||||
rtop = $('#replyrow').offset().top;
|
||||
rbottom = rtop + $('#replyrow').height();
|
||||
|
@ -1032,10 +1033,17 @@ window.commentReply = {
|
|||
else if ( rtop - 20 < scrollTop )
|
||||
window.scroll(0, rtop - 35);
|
||||
|
||||
$('#replycontent').trigger( 'focus' ).on( 'keyup', function(e){
|
||||
if ( e.which == 27 )
|
||||
commentReply.revert(); // Close on Escape.
|
||||
});
|
||||
$( '#replycontent' )
|
||||
.trigger( 'focus' )
|
||||
.on( 'keyup', function( e ) {
|
||||
// Close on Escape except when Input Method Editors (IMEs) are in use.
|
||||
if ( e.which === 27 && ! isComposing ) {
|
||||
commentReply.revert();
|
||||
}
|
||||
} )
|
||||
.on( 'compositionstart', function() {
|
||||
isComposing = true;
|
||||
} );
|
||||
}, 600);
|
||||
|
||||
return false;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.0-alpha-52950';
|
||||
$wp_version = '6.0-alpha-52951';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue