Skip to content

Commit

Permalink
Carousel: do not open modal when clicking on a link in a caption
Browse files Browse the repository at this point in the history
Fixes #10997

The new Core gallery block introduces a different markup for captions.
This PR makes sure that when clicking on a link in a caption inside a core gallery, you get redirected
to that link, instead of having the Carousel modal open.
  • Loading branch information
jeherve committed Dec 20, 2018
1 parent f21a311 commit bc87e82
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions modules/carousel/jetpack-carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1450,9 +1450,17 @@ jQuery(document).ready(function($) {
if ( ! $(this).jp_carousel( 'testForData', e.currentTarget ) ) {
return;
}

// Do not open the modal if we are looking at a gallery caption from before WP5, which may contain a link.
if ( $(e.target).parent().hasClass('gallery-caption') ) {
return;
}

// Do not open the modal if we are looking at a caption of a gallery block, which may contain a link.
if ( $(e.target).parent().is('figcaption') ) {
return;
}

e.preventDefault();

// Stopping propagation in case there are parent elements
Expand Down

0 comments on commit bc87e82

Please sign in to comment.