Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Editor] Enable the thickness input when no editors are selected (bug 1881219) #17757

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/display/editor/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,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],
]);
}
}
}

Expand Down
63 changes: 63 additions & 0 deletions test/integration/highlight_editor_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1266,4 +1266,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 + 5, rect.y + 5);
await page.mouse.down();
await page.mouse.move(rect.x + 100, rect.y + 100);
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])"
);
})
);
});
});
});