wp/wp-admin/js/edit-comments.js
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
--- a/wp/wp-admin/js/edit-comments.js	Fri Sep 05 18:40:08 2025 +0200
+++ b/wp/wp-admin/js/edit-comments.js	Fri Sep 05 18:52:52 2025 +0200
@@ -1020,7 +1020,8 @@
 
 		setTimeout(function() {
 			var rtop, rbottom, scrollTop, vp, scrollBottom,
-				isComposing = false;
+				isComposing = false,
+				isContextMenuOpen = false;
 
 			rtop = $('#replyrow').offset().top;
 			rbottom = rtop + $('#replyrow').height();
@@ -1035,9 +1036,20 @@
 
 			$( '#replycontent' )
 				.trigger( 'focus' )
+				.on( 'contextmenu keydown', function ( e ) {
+					// Check if the context menu is open and set state.
+					if ( e.type === 'contextmenu' ) {
+						isContextMenuOpen = true;
+					}
+
+					// Update the context menu state if the Escape key is pressed.
+					if ( e.type === 'keydown' && e.which === 27 && isContextMenuOpen ) {
+						isContextMenuOpen = false;
+					}
+				} )
 				.on( 'keyup', function( e ) {
-					// Close on Escape except when Input Method Editors (IMEs) are in use.
-					if ( e.which === 27 && ! isComposing ) {
+					// Close on Escape unless Input Method Editors (IMEs) are in use or the context menu is open.
+					if ( e.which === 27 && ! isComposing && ! isContextMenuOpen ) {
 						commentReply.revert();
 					}
 				} )
@@ -1188,6 +1200,7 @@
 		if ( er ) {
 			$errorNotice.removeClass( 'hidden' );
 			$error.html( er );
+			wp.a11y.speak( er );
 		}
 	},