Make WordPress Core

Changeset 52951


Ignore:
Timestamp:
03/18/2022 06:12:47 PM (3 years ago)
Author:
davidbaumwald
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/admin/edit-comments.js

    r50547 r52951  
    10201020
    10211021        setTimeout(function() {
    1022             var rtop, rbottom, scrollTop, vp, scrollBottom;
     1022            var rtop, rbottom, scrollTop, vp, scrollBottom,
     1023                isComposing = false;
    10231024
    10241025            rtop = $('#replyrow').offset().top;
     
    10331034                window.scroll(0, rtop - 35);
    10341035
    1035             $('#replycontent').trigger( 'focus' ).on( 'keyup', function(e){
    1036                 if ( e.which == 27 )
    1037                     commentReply.revert(); // Close on Escape.
    1038             });
     1036            $( '#replycontent' )
     1037                .trigger( 'focus' )
     1038                .on( 'keyup', function( e ) {
     1039                    // Close on Escape except when Input Method Editors (IMEs) are in use.
     1040                    if ( e.which === 27 && ! isComposing ) {
     1041                        commentReply.revert();
     1042                    }
     1043                } )
     1044                .on( 'compositionstart', function() {
     1045                    isComposing = true;
     1046                } );
    10391047        }, 600);
    10401048
Note: See TracChangeset for help on using the changeset viewer.