From 1ca7bc6718bb102f42561eb3fe4edf52eb031e29 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 19 Oct 2020 13:34:03 +0000 Subject: [PATCH] Embeds: Only catch clicks from the primary mouse button in the click handler, without any modifier keys. This ensures that Ctrl/Cmd + click to open a link in the embed iframe in a new tab works as expected. Props timhavinga, garrett-eclipse, smerriman, swissspidy, johnbillion, Mte90, iandunn, azaozz, afercia, audrasjb, SergeyBiryukov. Fixes #39097. git-svn-id: https://develop.svn.wordpress.org/trunk@49202 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/lib/embed-template.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/js/_enqueues/lib/embed-template.js b/src/js/_enqueues/lib/embed-template.js index 65b3a1b22f..86fb7d2c84 100644 --- a/src/js/_enqueues/lib/embed-template.js +++ b/src/js/_enqueues/lib/embed-template.js @@ -137,9 +137,7 @@ return; } - /** - * Send this document's height to the parent (embedding) site. - */ + // Send this document's height to the parent (embedding) site. sendEmbedMessage( 'height', Math.ceil( document.body.getBoundingClientRect().height ) ); // Send the document's height again after the featured image has been loaded. @@ -161,9 +159,12 @@ href = target.parentElement.getAttribute( 'href' ); } - /** - * Send link target to the parent (embedding) site. - */ + // Only catch clicks from the primary mouse button, without any modifiers. + if ( event.altKey || event.ctrlKey || event.metaKey || event.shiftKey ) { + return; + } + + // Send link target to the parent (embedding) site. if ( href ) { sendEmbedMessage( 'link', href ); e.preventDefault();