Skip to content

Commit ab7d388

Browse files
authored
Merge pull request #20591 from calixteman/reorg_fix_drag_width
Fix the drag marker dimensions in the thumbnails view
2 parents 001058a + f2ac669 commit ab7d388

3 files changed

Lines changed: 72 additions & 0 deletions

File tree

test/integration/reorganize_pages_spec.mjs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,4 +486,71 @@ describe("Reorganize Pages View", () => {
486486
);
487487
});
488488
});
489+
490+
describe("Drag marker must have the right non-zero dimensions", () => {
491+
let pages;
492+
493+
beforeEach(async () => {
494+
pages = await loadAndWait(
495+
"page_with_number_and_link.pdf",
496+
"#viewsManagerToggleButton",
497+
"1",
498+
null,
499+
{
500+
enableSplitMerge: true,
501+
sidebarViewOnLoad: 2 /* = SidebarView.OUTLINES */,
502+
}
503+
);
504+
});
505+
506+
afterEach(async () => {
507+
await closePages(pages);
508+
});
509+
510+
it("should check if the drag marker width is non-zero", async () => {
511+
await Promise.all(
512+
pages.map(async ([browserName, page]) => {
513+
await page.waitForSelector("#outlinesView", { visible: true });
514+
await page.waitForSelector("#viewsManagerSelectorButton", {
515+
visible: true,
516+
});
517+
await page.click("#viewsManagerSelectorButton");
518+
await page.waitForSelector("#thumbnailsViewMenu", { visible: true });
519+
await page.click("#thumbnailsViewMenu");
520+
521+
const thumbSelector = "#thumbnailsView .thumbnailImage";
522+
await page.waitForSelector(thumbSelector, { visible: true });
523+
const rect1 = await getRect(page, getThumbnailSelector(1));
524+
const rect2 = await getRect(page, getThumbnailSelector(2));
525+
526+
const handleAddedMarker = await waitForDOMMutation(
527+
page,
528+
mutationList => {
529+
for (const mutation of mutationList) {
530+
if (mutation.type !== "childList") {
531+
continue;
532+
}
533+
for (const node of mutation.addedNodes) {
534+
if (node.classList.contains("dragMarker")) {
535+
const rect = node.getBoundingClientRect();
536+
return rect.width !== 0;
537+
}
538+
}
539+
}
540+
return false;
541+
}
542+
);
543+
544+
await dragAndDrop(
545+
page,
546+
getThumbnailSelector(1),
547+
[[0, rect2.y - rect1.y + rect2.height / 2]],
548+
10
549+
);
550+
551+
await awaitPromise(handleAddedMarker);
552+
})
553+
);
554+
});
555+
});
489556
});

web/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ const PDFViewerApplication = {
388388
pageColorsBackground: x => x,
389389
pageColorsForeground: x => x,
390390
localeProperties: x => ({ lang: x }),
391+
sidebarViewOnLoad: x => parseInt(x),
391392
});
392393
}
393394

web/pdf_thumbnail_viewer.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,10 @@ class PDFThumbnailViewer {
635635
offsetWidth: w,
636636
offsetHeight: h,
637637
} = div;
638+
if (w === 0) {
639+
// The thumbnail view isn't visible.
640+
return;
641+
}
638642
bbox[i * 4] = x;
639643
bbox[i * 4 + 1] = y;
640644
bbox[i * 4 + 2] = w;

0 commit comments

Comments
 (0)