diff --git a/src/display/editor/tools.js b/src/display/editor/tools.js index 819081046..ea6a66229 100644 --- a/src/display/editor/tools.js +++ b/src/display/editor/tools.js @@ -711,7 +711,9 @@ class AnnotationEditorUIManager { // Those shortcuts can be used in the toolbar for some other actions // like zooming, hence we need to check if the container has the // focus. - checker: self => self.#container.contains(document.activeElement), + checker: (self, { target: el }) => + !(el instanceof HTMLButtonElement) && + self.#container.contains(document.activeElement), }, ], [["Escape", "mac+Escape"], proto.unselectAll], diff --git a/test/integration/highlight_editor_spec.mjs b/test/integration/highlight_editor_spec.mjs index e67a35eaa..786e1fb35 100644 --- a/test/integration/highlight_editor_spec.mjs +++ b/test/integration/highlight_editor_spec.mjs @@ -1231,4 +1231,39 @@ describe("Highlight Editor", () => { ); }); }); + + describe("Editor must be removed in using the space key on the delete button", () => { + let pages; + + beforeAll(async () => { + pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); + }); + + afterAll(async () => { + await closePages(pages); + }); + + it("must check that the highlight has been deleted", async () => { + await Promise.all( + pages.map(async ([browserName, page]) => { + await page.click("#editorHighlight"); + await page.waitForSelector(".annotationEditorLayer.highlightEditing"); + + const rect = await getSpanRectFromText(page, 1, "Abstract"); + const x = rect.x + rect.width / 2; + const y = rect.y + rect.height / 2; + await page.mouse.click(x, y, { count: 2, delay: 100 }); + + await page.waitForSelector(getEditorSelector(0)); + await waitForSerialized(page, 1); + await page.waitForSelector(`${getEditorSelector(0)} button.delete`); + + await page.focus(`${getEditorSelector(0)} button.delete`); + await page.keyboard.press(" "); + + await waitForSerialized(page, 0); + }) + ); + }); + }); });