mirror of
https://github.com/documenso/documenso.git
synced 2026-06-22 04:12:06 +10:00
fix: wip
This commit is contained in:
@@ -262,8 +262,6 @@ test.describe('PDF Viewer Rendering', () => {
|
|||||||
|
|
||||||
await fileChooser.setFiles(path.join(__dirname, '../../../../assets/example.pdf'));
|
await fileChooser.setFiles(path.join(__dirname, '../../../../assets/example.pdf'));
|
||||||
|
|
||||||
await page.waitForTimeout(2000);
|
|
||||||
|
|
||||||
await page.getByRole('button', { name: 'Continue' }).click();
|
await page.getByRole('button', { name: 'Continue' }).click();
|
||||||
|
|
||||||
await expect(page.locator(PDF_PAGE_SELECTOR).first()).toBeVisible({ timeout: 30_000 });
|
await expect(page.locator(PDF_PAGE_SELECTOR).first()).toBeVisible({ timeout: 30_000 });
|
||||||
|
|||||||
@@ -91,10 +91,19 @@ export const useFieldPageCoords = (
|
|||||||
const mutationObserver = new MutationObserver(() => {
|
const mutationObserver = new MutationObserver(() => {
|
||||||
const $page = document.querySelector<HTMLElement>(pageSelector);
|
const $page = document.querySelector<HTMLElement>(pageSelector);
|
||||||
|
|
||||||
if ($page) {
|
if (!$page) {
|
||||||
calculateCoords();
|
return;
|
||||||
attachResizeObserver($page);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only recalculate when the observed page element has changed (e.g. new
|
||||||
|
// element appeared after virtual list scroll). Skip when mutations are
|
||||||
|
// from elsewhere in the DOM and the page element is unchanged.
|
||||||
|
if ($page === observedElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
calculateCoords();
|
||||||
|
attachResizeObserver($page);
|
||||||
});
|
});
|
||||||
|
|
||||||
mutationObserver.observe(document.body, {
|
mutationObserver.observe(document.body, {
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ export const usePageRenderer = (renderFunction: RenderFunction, pageData: PageRe
|
|||||||
const imageProps = useMemo(
|
const imageProps = useMemo(
|
||||||
(): React.ImgHTMLAttributes<HTMLImageElement> & Record<string, unknown> & { alt: '' } => ({
|
(): React.ImgHTMLAttributes<HTMLImageElement> & Record<string, unknown> & { alt: '' } => ({
|
||||||
className: PDF_VIEWER_PAGE_CLASSNAME,
|
className: PDF_VIEWER_PAGE_CLASSNAME,
|
||||||
width: `${Math.floor(scaledViewport.width)}px`,
|
width: Math.floor(scaledViewport.width),
|
||||||
height: `${Math.floor(scaledViewport.height)}px`,
|
height: Math.floor(scaledViewport.height),
|
||||||
alt: '',
|
alt: '',
|
||||||
onLoad: () => setRenderStatus('loaded'),
|
onLoad: () => setRenderStatus('loaded'),
|
||||||
// Purposely not using lazy here since we can use the virtual list overscan to let us prerender images.
|
// Purposely not using lazy here since we can use the virtual list overscan to let us prerender images.
|
||||||
|
|||||||
Reference in New Issue
Block a user