Fix image blocks zoomable behaviour (#2756)

This commit is contained in:
Taran Vohra
2025-01-20 13:22:12 +05:30
committed by GitHub
parent 38de9eb9d7
commit 1b8a45678c
4 changed files with 23 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'gitbook': patch
---
Fix Image blocks zoomable behaviour
+15
View File
@@ -378,6 +378,21 @@ const testCases: TestsCase[] = [
fullPage: true,
screenshot: { threshold: 0.8 },
},
{
name: 'Images (with zoom)',
url: 'blocks/block-images',
run: async (page) => {
await waitForCookiesDialog(page);
const zoomImage = page.getByTestId('zoom-image');
if (!zoomImage) {
throw new Error('Image block not found');
}
await zoomImage.first().click();
await page.waitForSelector('[data-testid="zoom-image-modal"]');
},
fullPage: true,
screenshot: { threshold: 0.8 },
},
{
name: 'Inline Images',
url: 'blocks/inline-images',
@@ -39,6 +39,7 @@ export function Caption(
'after:block',
'after:absolute',
'after:-inset-[0]',
'after:pointer-events-none',
fit ? 'w-fit' : null,
withBorder
? 'rounded straight-corners:rounded-none after:border-dark/2 after:border after:rounded straight-corners:after:rounded-none dark:after:border-light/1 dark:after:mix-blend-plus-lighter after:pointer-events-none'
@@ -142,6 +142,7 @@ export function ZoomImage(
) : (
// When zooming, remove the image from the DOM to let the browser animates it with View Transition.
<img
data-testid="zoom-image"
ref={imgRef}
{...props}
alt={alt ?? ''}
@@ -206,6 +207,7 @@ function ZoomImageModal(props: {
return (
<div
data-testid="zoom-image-modal"
className={classNames(
styles.zoomModal,
tcls(