diff --git a/src/display/editor/tools.js b/src/display/editor/tools.js index 819081046ab473..cf7f297e957823 100644 --- a/src/display/editor/tools.js +++ b/src/display/editor/tools.js @@ -1296,6 +1296,17 @@ class AnnotationEditorUIManager { source: this, details: Object.assign(this.#previousStates, details), }); + // We could listen on our own event but it sounds like a bit weird and + // it's a way to simpler to handle that stuff here instead of having to + // add something in every place where an editor can be unselected. + if ( + this.#mode === AnnotationEditorType.HIGHLIGHT && + details.hasSelectedEditor === false + ) { + this.#dispatchUpdateUI([ + [AnnotationEditorParamsType.HIGHLIGHT_FREE, true], + ]); + } } } diff --git a/test/integration/highlight_editor_spec.mjs b/test/integration/highlight_editor_spec.mjs index e67a35eaa71e3b..0d47758117c7b7 100644 --- a/test/integration/highlight_editor_spec.mjs +++ b/test/integration/highlight_editor_spec.mjs @@ -1231,4 +1231,67 @@ describe("Highlight Editor", () => { ); }); }); + + describe("Thickness must be enabled when there's no selected highlights", () => { + let pages; + + beforeAll(async () => { + pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); + }); + + afterAll(async () => { + await closePages(pages); + }); + + it("must check the thickness input state", async () => { + await Promise.all( + pages.map(async ([browserName, page]) => { + await page.click("#editorHighlight"); + await page.waitForSelector(".annotationEditorLayer.highlightEditing"); + + let rect = await getSpanRectFromText(page, 1, "Abstract"); + await page.mouse.click( + rect.x + rect.width / 2, + rect.y + rect.height / 2, + { count: 2, delay: 100 } + ); + + await page.waitForSelector(getEditorSelector(0)); + + rect = await page.$eval(".annotationEditorLayer", el => { + const { x, y } = el.getBoundingClientRect(); + return { x, y }; + }); + + const clickHandle = await waitForPointerUp(page); + await page.mouse.move(rect.x + 120, rect.y + 120); + await page.mouse.down(); + await page.mouse.move(rect.x + 220, rect.y + 220); + await page.mouse.up(); + await awaitPromise(clickHandle); + + await page.waitForSelector(getEditorSelector(1)); + await page.waitForSelector( + "#editorFreeHighlightThickness:not([disabled])" + ); + + await page.click(getEditorSelector(0)); + await page.waitForSelector(getEditorSelector(0)); + await page.waitForSelector("#editorFreeHighlightThickness[disabled]"); + + await page.click("#editorHighlight"); + await page.waitForSelector( + ".annotationEditorLayer:not(.highlightEditing)" + ); + + await page.click("#editorHighlight"); + await page.waitForSelector(".annotationEditorLayer.highlightEditing"); + + await page.waitForSelector( + "#editorFreeHighlightThickness:not([disabled])" + ); + }) + ); + }); + }); });