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
This commit is contained in:
Sergey Biryukov 2020-10-19 13:34:03 +00:00
parent 4362706c10
commit 1ca7bc6718

View File

@ -137,9 +137,7 @@
return; 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 ) ); sendEmbedMessage( 'height', Math.ceil( document.body.getBoundingClientRect().height ) );
// Send the document's height again after the featured image has been loaded. // Send the document's height again after the featured image has been loaded.
@ -161,9 +159,12 @@
href = target.parentElement.getAttribute( 'href' ); href = target.parentElement.getAttribute( 'href' );
} }
/** // Only catch clicks from the primary mouse button, without any modifiers.
* Send link target to the parent (embedding) site. if ( event.altKey || event.ctrlKey || event.metaKey || event.shiftKey ) {
*/ return;
}
// Send link target to the parent (embedding) site.
if ( href ) { if ( href ) {
sendEmbedMessage( 'link', href ); sendEmbedMessage( 'link', href );
e.preventDefault(); e.preventDefault();