Merge pull request #20307 from calixteman/bug1990872

[Editor] Make sure the selected editor is correctly focused after switching editing mode (bug 1990872)
This commit is contained in:
calixteman 2025-09-26 09:17:48 +02:00 committed by GitHub
commit 7051fd0215
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 79 additions and 0 deletions

View File

@ -2129,6 +2129,12 @@ class AnnotationEditor {
this.#altText?.toggleAltTextBadge(false);
}
focus() {
if (this.div && !this.div.contains(document.activeElement)) {
setTimeout(() => this.div?.focus({ preventScroll: true }), 0);
}
}
/**
* Unselect this editor.
*/

View File

@ -1948,6 +1948,8 @@ class AnnotationEditorUIManager {
editor.editComment();
} else if (mustEnterInEditMode) {
editor.enterInEditMode();
} else {
editor.focus();
}
} else {
editor.unselect();

View File

@ -31,6 +31,7 @@ import {
kbUndo,
loadAndWait,
scrollIntoView,
selectEditor,
selectEditors,
setCaretAt,
switchToEditor,
@ -2953,4 +2954,74 @@ describe("Highlight Editor", () => {
);
});
});
describe("An ink between two highlights and focus", () => {
let pages;
beforeEach(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
".annotationEditorLayer",
null,
null,
{ highlightEditorColors: "red=#AB0000" }
);
});
afterEach(async () => {
await closePages(pages);
});
it("must check that focus move from an editor to an other", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await switchToHighlight(page);
let rect = await getSpanRectFromText(page, 1, "Languages");
await page.mouse.click(
rect.x + rect.width / 2,
rect.y + rect.height / 2,
{ count: 2, delay: 100 }
);
const editorSelector0 = getEditorSelector(0);
await page.waitForSelector(editorSelector0);
rect = await getSpanRectFromText(page, 1, "Abstract");
await page.mouse.click(
rect.x + rect.width / 2,
rect.y + rect.height / 2,
{ count: 2, delay: 100 }
);
const editorSelector1 = getEditorSelector(1);
await page.waitForSelector(editorSelector1);
await switchToEditor("Ink", page);
rect = await getSpanRectFromText(
page,
1,
"University of California, Irvine"
);
const clickHandle = await waitForPointerUp(page);
await page.mouse.move(rect.x, rect.y);
await page.mouse.down();
await page.mouse.move(rect.x + 50, rect.y + 50);
await page.mouse.up();
await awaitPromise(clickHandle);
await page.keyboard.press("Escape");
await page.waitForSelector(
".inkEditor.selectedEditor.draggable.disabled"
);
await selectEditor(page, editorSelector0);
for (let i = 0; i < 6; i++) {
await page.keyboard.press("Tab", { delay: 100 });
}
await waitForSelectedEditor(page, editorSelector1);
})
);
});
});
});