Make WordPress Core

Changeset 49202


Ignore:
Timestamp:
10/19/2020 01:34:03 PM (4 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/lib/embed-template.js

    r46586 r49202  
    138138        }
    139139
    140         /**
    141          * Send this document's height to the parent (embedding) site.
    142          */
     140        // Send this document's height to the parent (embedding) site.
    143141        sendEmbedMessage( 'height', Math.ceil( document.body.getBoundingClientRect().height ) );
    144142
     
    162160            }
    163161
    164             /**
    165              * Send link target to the parent (embedding) site.
    166              */
     162            // Only catch clicks from the primary mouse button, without any modifiers.
     163            if ( event.altKey || event.ctrlKey || event.metaKey || event.shiftKey ) {
     164                return;
     165            }
     166
     167            // Send link target to the parent (embedding) site.
    167168            if ( href ) {
    168169                sendEmbedMessage( 'link', href );
Note: See TracChangeset for help on using the changeset viewer.