Merge pull request #20591 from calixteman/reorg_fix_drag_width

Fix the drag marker dimensions in the thumbnails view
This commit is contained in:
calixteman 2026-01-26 09:00:01 +01:00 committed by GitHub
commit ab7d388ccb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 72 additions and 0 deletions

View File

@ -486,4 +486,71 @@ describe("Reorganize Pages View", () => {
);
});
});
describe("Drag marker must have the right non-zero dimensions", () => {
let pages;
beforeEach(async () => {
pages = await loadAndWait(
"page_with_number_and_link.pdf",
"#viewsManagerToggleButton",
"1",
null,
{
enableSplitMerge: true,
sidebarViewOnLoad: 2 /* = SidebarView.OUTLINES */,
}
);
});
afterEach(async () => {
await closePages(pages);
});
it("should check if the drag marker width is non-zero", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await page.waitForSelector("#outlinesView", { visible: true });
await page.waitForSelector("#viewsManagerSelectorButton", {
visible: true,
});
await page.click("#viewsManagerSelectorButton");
await page.waitForSelector("#thumbnailsViewMenu", { visible: true });
await page.click("#thumbnailsViewMenu");
const thumbSelector = "#thumbnailsView .thumbnailImage";
await page.waitForSelector(thumbSelector, { visible: true });
const rect1 = await getRect(page, getThumbnailSelector(1));
const rect2 = await getRect(page, getThumbnailSelector(2));
const handleAddedMarker = await waitForDOMMutation(
page,
mutationList => {
for (const mutation of mutationList) {
if (mutation.type !== "childList") {
continue;
}
for (const node of mutation.addedNodes) {
if (node.classList.contains("dragMarker")) {
const rect = node.getBoundingClientRect();
return rect.width !== 0;
}
}
}
return false;
}
);
await dragAndDrop(
page,
getThumbnailSelector(1),
[[0, rect2.y - rect1.y + rect2.height / 2]],
10
);
await awaitPromise(handleAddedMarker);
})
);
});
});
});

View File

@ -388,6 +388,7 @@ const PDFViewerApplication = {
pageColorsBackground: x => x,
pageColorsForeground: x => x,
localeProperties: x => ({ lang: x }),
sidebarViewOnLoad: x => parseInt(x),
});
}

View File

@ -635,6 +635,10 @@ class PDFThumbnailViewer {
offsetWidth: w,
offsetHeight: h,
} = div;
if (w === 0) {
// The thumbnail view isn't visible.
return;
}
bbox[i * 4] = x;
bbox[i * 4 + 1] = y;
bbox[i * 4 + 2] = w;