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:
commit
7051fd0215
@ -2129,6 +2129,12 @@ class AnnotationEditor {
|
|||||||
this.#altText?.toggleAltTextBadge(false);
|
this.#altText?.toggleAltTextBadge(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
focus() {
|
||||||
|
if (this.div && !this.div.contains(document.activeElement)) {
|
||||||
|
setTimeout(() => this.div?.focus({ preventScroll: true }), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unselect this editor.
|
* Unselect this editor.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1948,6 +1948,8 @@ class AnnotationEditorUIManager {
|
|||||||
editor.editComment();
|
editor.editComment();
|
||||||
} else if (mustEnterInEditMode) {
|
} else if (mustEnterInEditMode) {
|
||||||
editor.enterInEditMode();
|
editor.enterInEditMode();
|
||||||
|
} else {
|
||||||
|
editor.focus();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
editor.unselect();
|
editor.unselect();
|
||||||
|
|||||||
@ -31,6 +31,7 @@ import {
|
|||||||
kbUndo,
|
kbUndo,
|
||||||
loadAndWait,
|
loadAndWait,
|
||||||
scrollIntoView,
|
scrollIntoView,
|
||||||
|
selectEditor,
|
||||||
selectEditors,
|
selectEditors,
|
||||||
setCaretAt,
|
setCaretAt,
|
||||||
switchToEditor,
|
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);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user