Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image Block: Change how the Image's overlay styles are applied #67788

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading