From 272df00b1760ea73adb826015bbaa8e97981fff6 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 19 Oct 2020 13:36:08 +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. Built from https://develop.svn.wordpress.org/trunk@49202 git-svn-id: http://core.svn.wordpress.org/trunk@48964 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/embed.php | 2 +- wp-includes/js/wp-embed-template.js | 13 +++++++------ wp-includes/js/wp-embed-template.min.js | 2 +- wp-includes/version.php | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/wp-includes/embed.php b/wp-includes/embed.php index 80c9ba0980..34db507584 100644 --- a/wp-includes/embed.php +++ b/wp-includes/embed.php @@ -1072,7 +1072,7 @@ function print_embed_scripts() { */ ?> /*! This file is auto-generated */ - !function(u,c){"use strict";var r,t,e,i=c.querySelector&&u.addEventListener,b=!1;function f(e,t){u.parent.postMessage({message:e,value:t,secret:r},"*")}function n(){if(!b){b=!0;var e,t=c.querySelector(".wp-embed-share-dialog"),r=c.querySelector(".wp-embed-share-dialog-open"),i=c.querySelector(".wp-embed-share-dialog-close"),n=c.querySelectorAll(".wp-embed-share-input"),a=c.querySelectorAll(".wp-embed-share-tab-button button"),o=c.querySelector(".wp-embed-featured-image img");if(n)for(e=0;e diff --git a/wp-includes/js/wp-embed-template.js b/wp-includes/js/wp-embed-template.js index 65b3a1b22f..86fb7d2c84 100644 --- a/wp-includes/js/wp-embed-template.js +++ b/wp-includes/js/wp-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(); diff --git a/wp-includes/js/wp-embed-template.min.js b/wp-includes/js/wp-embed-template.min.js index 0ef41267a3..e9040a2794 100644 --- a/wp-includes/js/wp-embed-template.min.js +++ b/wp-includes/js/wp-embed-template.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -!function(u,c){"use strict";var r,t,e,i=c.querySelector&&u.addEventListener,b=!1;function f(e,t){u.parent.postMessage({message:e,value:t,secret:r},"*")}function n(){if(!b){b=!0;var e,t=c.querySelector(".wp-embed-share-dialog"),r=c.querySelector(".wp-embed-share-dialog-open"),i=c.querySelector(".wp-embed-share-dialog-close"),n=c.querySelectorAll(".wp-embed-share-input"),a=c.querySelectorAll(".wp-embed-share-tab-button button"),o=c.querySelector(".wp-embed-featured-image img");if(n)for(e=0;e