Skip to content

Commit 583bbce

Browse files
committed
Comments: Limit comments shortcut to not execute on links.
Exclude links from activating the comment submission shortcut. [45790] introduced a shortcut to submit comment forms using `Ctrl/Cmd + Enter`. This keyboard combination is also the combination for opening a link in a new tab, which resulted in submitting the form when using the Log Out or Edit Profile links. Props greentreefrog, sabernhardt, narenin. Fixes #61919. git-svn-id: https://develop.svn.wordpress.org/trunk@58981 602fd350-edb4-49c9-b593-d223f7449a82
1 parent c5a5c20 commit 583bbce

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/js/_enqueues/lib/comment-reply.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ window.addComment = ( function( window ) {
9898

9999
// Submit the comment form when the user types [Ctrl] or [Cmd] + [Enter].
100100
var submitFormHandler = function( e ) {
101-
if ( ( e.metaKey || e.ctrlKey ) && e.keyCode === 13 ) {
101+
if ( ( e.metaKey || e.ctrlKey ) && e.keyCode === 13 && document.activeElement.tagName.toLowerCase() !== 'a' ) {
102102
commentFormElement.removeEventListener( 'keydown', submitFormHandler );
103103
e.preventDefault();
104104
// The submit button ID is 'submit' so we can't call commentFormElement.submit(). Click it instead.

0 commit comments

Comments
 (0)