You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Image block: lightbox trigger button is mispositioned when the img is wrapped #82283
setButtonStyles measures ref.parentElement (view.js#L621-L629), assuming the img is a direct child of the figure. When a plugin wraps the img — for example Modern Image Formats' <picture style="display: contents"> — that wrapper generates no box, so clientWidth/clientHeight read 0, the button gets right: -offsetWidth + 16, and the page scrolls horizontally. figure.querySelector( 'figcaption' ) on the next line also returns null, so the caption height is never subtracted.
Proposed fix: use ref.closest( '.wp-lightbox-container' ). That is the element the button is positioned against (.wp-lightbox-container is position: relative, the button position: absolute), it is guaranteed present since block_core_image_render_lightbox() adds the class, and it resolves to the same node as parentElement for unwrapped images.
#57089 made the trigger button ref resilient to the same wrapping.
Step-by-step reproduction instructions
Install Modern Image Formats; enable "Generate JPEG and WebP" and the picture element setting under Settings → Media.
Upload a JPEG, add it to an Image block, enable "Expand on click".
View the post at a ~500px viewport.
The trigger button renders outside the figure and the page scrolls horizontally.
Activity