Merge pull request #19371 from Snuffleupagus/issue-19369
[Editor] Ensure that `highlightSelection` waits until we've fully updated the editing-mode (issue 19369)
This commit is contained in:
commit
2132552d71
@ -1481,23 +1481,33 @@ describe("Highlight Editor", () => {
|
|||||||
it("must check that clicking on the highlight floating button triggers an highlight", async () => {
|
it("must check that clicking on the highlight floating button triggers an highlight", async () => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
pages.map(async ([browserName, page]) => {
|
pages.map(async ([browserName, page]) => {
|
||||||
const rect = await getSpanRectFromText(page, 1, "Abstract");
|
async function floatingHighlight(text, editorId) {
|
||||||
const x = rect.x + rect.width / 2;
|
const rect = await getSpanRectFromText(page, 1, text);
|
||||||
const y = rect.y + rect.height / 2;
|
const x = rect.x + rect.width / 2;
|
||||||
await page.mouse.click(x, y, { count: 2, delay: 100 });
|
const y = rect.y + rect.height / 2;
|
||||||
|
await page.mouse.click(x, y, { count: 2, delay: 100 });
|
||||||
|
|
||||||
await page.waitForSelector(".textLayer .highlightButton");
|
await page.waitForSelector(".textLayer .highlightButton");
|
||||||
await page.click(".textLayer .highlightButton");
|
await page.click(".textLayer .highlightButton");
|
||||||
|
|
||||||
await page.waitForSelector(getEditorSelector(0));
|
await page.waitForSelector(getEditorSelector(editorId));
|
||||||
const usedColor = await page.evaluate(() => {
|
const usedColor = await page.evaluate(() => {
|
||||||
const highlight = document.querySelector(
|
const highlight = document.querySelector(
|
||||||
`.page[data-page-number = "1"] .canvasWrapper > svg.highlight`
|
`.page[data-page-number = "1"] .canvasWrapper > svg.highlight`
|
||||||
);
|
);
|
||||||
return highlight.getAttribute("fill");
|
return highlight.getAttribute("fill");
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(usedColor).withContext(`In ${browserName}`).toEqual("#AB0000");
|
expect(usedColor)
|
||||||
|
.withContext(`In ${browserName}`)
|
||||||
|
.toEqual("#AB0000");
|
||||||
|
}
|
||||||
|
|
||||||
|
await floatingHighlight("Abstract", 0);
|
||||||
|
|
||||||
|
// Disable editing mode, and highlight another string (issue 19369).
|
||||||
|
await switchToHighlight(page, /* disable */ true);
|
||||||
|
await floatingHighlight("Introduction", 1);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -2339,11 +2339,22 @@ class PDFViewer {
|
|||||||
this.#mlManager?.loadModel("altText");
|
this.#mlManager?.loadModel("altText");
|
||||||
}
|
}
|
||||||
|
|
||||||
const { eventBus } = this;
|
const { eventBus, pdfDocument } = this;
|
||||||
const updater = () => {
|
const updater = async () => {
|
||||||
this.#cleanupSwitchAnnotationEditorMode();
|
this.#cleanupSwitchAnnotationEditorMode();
|
||||||
this.#annotationEditorMode = mode;
|
this.#annotationEditorMode = mode;
|
||||||
this.#annotationEditorUIManager.updateMode(mode, editId, isFromKeyboard);
|
await this.#annotationEditorUIManager.updateMode(
|
||||||
|
mode,
|
||||||
|
editId,
|
||||||
|
isFromKeyboard
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
mode !== this.#annotationEditorMode ||
|
||||||
|
pdfDocument !== this.pdfDocument
|
||||||
|
) {
|
||||||
|
// Since `updateMode` is async, the active mode could have changed.
|
||||||
|
return;
|
||||||
|
}
|
||||||
eventBus.dispatch("annotationeditormodechanged", {
|
eventBus.dispatch("annotationeditormodechanged", {
|
||||||
source: this,
|
source: this,
|
||||||
mode,
|
mode,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user