mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-13 18:45:52 +02:00
Merge pull request #20926 from calixteman/bug2022516
Correctly focus the pasted page (bug 2022516)
This commit is contained in:
commit
5bdeb79b09
@ -1271,6 +1271,68 @@ describe("Reorganize Pages View", () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should focus the newly pasted page after copy and paste (bug 2022516)", async () => {
|
||||||
|
await Promise.all(
|
||||||
|
pages.map(async ([browserName, page]) => {
|
||||||
|
await waitForThumbnailVisible(page, 1);
|
||||||
|
await page.waitForSelector("#viewsManagerStatusActionButton", {
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Select page 1 and copy it.
|
||||||
|
await waitAndClick(
|
||||||
|
page,
|
||||||
|
`.thumbnail:has(${getThumbnailSelector(1)}) input`
|
||||||
|
);
|
||||||
|
let handlePagesEdited = await waitForPagesEdited(page, "copy");
|
||||||
|
await waitAndClick(page, "#viewsManagerStatusActionButton");
|
||||||
|
await waitAndClick(page, "#viewsManagerStatusActionCopy");
|
||||||
|
await awaitPromise(handlePagesEdited);
|
||||||
|
|
||||||
|
// Paste after page 3: the pasted page lands at position 4.
|
||||||
|
handlePagesEdited = await waitForPagesEdited(page);
|
||||||
|
await waitAndClick(page, `${getThumbnailSelector(3)}+button`);
|
||||||
|
await awaitPromise(handlePagesEdited);
|
||||||
|
|
||||||
|
// Focus must be on the newly pasted page (position 4), not page 1.
|
||||||
|
await page.waitForSelector(`${getThumbnailSelector(4)}:focus`, {
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should focus the newly pasted page after cut and paste (bug 2022516)", async () => {
|
||||||
|
await Promise.all(
|
||||||
|
pages.map(async ([browserName, page]) => {
|
||||||
|
await waitForThumbnailVisible(page, 1);
|
||||||
|
await page.waitForSelector("#viewsManagerStatusActionButton", {
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Select page 3 and cut it.
|
||||||
|
await waitAndClick(
|
||||||
|
page,
|
||||||
|
`.thumbnail:has(${getThumbnailSelector(3)}) input`
|
||||||
|
);
|
||||||
|
let handlePagesEdited = await waitForPagesEdited(page, "cut");
|
||||||
|
await waitAndClick(page, "#viewsManagerStatusActionButton");
|
||||||
|
await waitAndClick(page, "#viewsManagerStatusActionCut");
|
||||||
|
await awaitPromise(handlePagesEdited);
|
||||||
|
|
||||||
|
// Paste after page 1: the pasted page lands at position 2.
|
||||||
|
handlePagesEdited = await waitForPagesEdited(page);
|
||||||
|
await waitAndClick(page, `${getThumbnailSelector(1)}+button`);
|
||||||
|
await awaitPromise(handlePagesEdited);
|
||||||
|
|
||||||
|
// Focus must be on the newly pasted page (position 2), not page 1.
|
||||||
|
await page.waitForSelector(`${getThumbnailSelector(2)}:focus`, {
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Status label reflects number of checked thumbnails (bug 2010832)", () => {
|
describe("Status label reflects number of checked thumbnails (bug 2010832)", () => {
|
||||||
|
|||||||
@ -730,13 +730,13 @@ class PDFThumbnailViewer {
|
|||||||
this.#selectedPages.clear();
|
this.#selectedPages.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
#updateCurrentPage(currentPageNumber) {
|
#updateCurrentPage(currentPageNumber, forceFocus = false) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.forceRendering();
|
this.forceRendering();
|
||||||
const newPageNumber = currentPageNumber || 1;
|
const newPageNumber = currentPageNumber || 1;
|
||||||
this.linkService.goToPage(newPageNumber);
|
this.linkService.goToPage(newPageNumber);
|
||||||
const thumbnailView = this._thumbnails[newPageNumber - 1];
|
const thumbnailView = this._thumbnails[newPageNumber - 1];
|
||||||
if (!this.container.contains(document.activeElement)) {
|
if (forceFocus || !this.container.contains(document.activeElement)) {
|
||||||
thumbnailView.imageContainer.focus();
|
thumbnailView.imageContainer.focus();
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
@ -898,7 +898,8 @@ class PDFThumbnailViewer {
|
|||||||
: this._currentPageNumber;
|
: this._currentPageNumber;
|
||||||
|
|
||||||
pagesMapper.pastePages(index);
|
pagesMapper.pastePages(index);
|
||||||
this.#updateCurrentPage(this.#updateThumbnails(currentPageNumber));
|
this.#updateThumbnails(currentPageNumber);
|
||||||
|
this.#updateCurrentPage(index + 1, /* forceFocus = */ true);
|
||||||
this.#computeThumbnailsPosition();
|
this.#computeThumbnailsPosition();
|
||||||
|
|
||||||
this.eventBus.dispatch("pagesedited", {
|
this.eventBus.dispatch("pagesedited", {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user