Skip to content

Commit

Permalink
Image Block: Change how the Image's overlay styles are applied (#67788)
Browse files Browse the repository at this point in the history
Co-authored-by: DAreRodz <[email protected]>
Co-authored-by: SantosGuillamot <[email protected]>
  • Loading branch information
3 people authored Dec 10, 2024
1 parent 9a63c4b commit da012ed
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/block-library/src/image/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ class="wp-lightbox-overlay zoom"
data-wp-on-async--click="actions.hideLightbox"
data-wp-on-async-window--resize="callbacks.setOverlayStyles"
data-wp-on-async-window--scroll="actions.handleScroll"
data-wp-bind--style="state.overlayStyles"
tabindex="-1"
>
<button type="button" aria-label="$close_button_label" style="fill: $close_button_color" class="close-button">
Expand All @@ -306,7 +307,6 @@ class="wp-lightbox-overlay zoom"
</figure>
</div>
<div class="scrim" style="background-color: $background_color" aria-hidden="true"></div>
<style data-wp-text="state.overlayStyles"></style>
</div>
HTML;
}
Expand Down
4 changes: 1 addition & 3 deletions packages/block-library/src/image/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ const { state, actions, callbacks } = store(
// adding 1 pixel to the container width and height solves the problem,
// though this can be removed if the issue is fixed in the future.
state.overlayStyles = `
:root {
--wp--lightbox-initial-top-position: ${ screenPosY }px;
--wp--lightbox-initial-left-position: ${ screenPosX }px;
--wp--lightbox-container-width: ${ containerWidth + 1 }px;
Expand All @@ -352,8 +351,7 @@ const { state, actions, callbacks } = store(
--wp--lightbox-scrollbar-width: ${
window.innerWidth - document.documentElement.clientWidth
}px;
}
`;
`;
},
setButtonStyles() {
const { imageId } = getContext();
Expand Down

0 comments on commit da012ed

Please sign in to comment.