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 page.waitForTimeout(2000);
|
||||
|
||||
await page.getByRole('button', { name: 'Continue' }).click();
|
||||
|
||||
await expect(page.locator(PDF_PAGE_SELECTOR).first()).toBeVisible({ timeout: 30_000 });
|
||||
|
||||
@@ -91,10 +91,19 @@ export const useFieldPageCoords = (
|
||||
const mutationObserver = new MutationObserver(() => {
|
||||
const $page = document.querySelector<HTMLElement>(pageSelector);
|
||||
|
||||
if ($page) {
|
||||
calculateCoords();
|
||||
attachResizeObserver($page);
|
||||
if (!$page) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 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, {
|
||||
|
||||
@@ -61,8 +61,8 @@ export const usePageRenderer = (renderFunction: RenderFunction, pageData: PageRe
|
||||
const imageProps = useMemo(
|
||||
(): React.ImgHTMLAttributes<HTMLImageElement> & Record<string, unknown> & { alt: '' } => ({
|
||||
className: PDF_VIEWER_PAGE_CLASSNAME,
|
||||
width: `${Math.floor(scaledViewport.width)}px`,
|
||||
height: `${Math.floor(scaledViewport.height)}px`,
|
||||
width: Math.floor(scaledViewport.width),
|
||||
height: Math.floor(scaledViewport.height),
|
||||
alt: '',
|
||||
onLoad: () => setRenderStatus('loaded'),
|
||||
// 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