fancyapps / fancybox

jQuery lightbox script for displaying images, videos and more. Touch enabled, responsive and fully customizable.
http://fancyapps.com/
7.28k stars 1.78k forks source link

Previous image caption not cleared if next image caption is empty #2424

Open likemusic opened 4 years ago

likemusic commented 4 years ago

Describe the bug If some images in gallery don't have caption or have empty caption, caption text for these images not cleared when navigate by images infancybox.

Bug demo: https://jsfiddle.net/Lo2mxu36/1/

To Reproduce Steps to reproduce the behavior:

  1. Create fancybox galley with some images without caption.
  2. Click on image with caption to open fancybox.
  3. Click next/prev to go to image without caption.
  4. See that caption is not empty but have value from latest viewed image with caption.

Expected behavior Caption contains actual value for current image. If image doesn't have caption or have empty caption, caption block in fancybox should be also be empty.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

Seems that problem is here https://github.com/fancyapps/fancybox/blob/master/src/js/core.js#L2955 in if-state.

$caption.children().eq(0).html(caption) - should be called even if caption is empty.

fancyapps commented 4 years ago

Hi,

Hmm, true. sorry about that. You could, of course, clear caption using callbacks, if needed, but that will be included in the next update.