Skip to content

Commit

Permalink
Merge pull request #18697 from calixteman/issue18696
Browse files Browse the repository at this point in the history
[Editor] Avoid to throw when an highlight annotation is resetted
  • Loading branch information
calixteman authored Sep 5, 2024
2 parents e3fd62d + 350e3e7 commit 4b906ad
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/display/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1796,7 +1796,7 @@ class AnnotationEditor {
resetAnnotationElement(annotation) {
const { firstChild } = annotation.container;
if (
firstChild.nodeName === "DIV" &&
firstChild?.nodeName === "DIV" &&
firstChild.classList.contains("annotationContent")
) {
firstChild.remove();
Expand Down
33 changes: 33 additions & 0 deletions test/integration/highlight_editor_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2020,4 +2020,37 @@ describe("Highlight Editor", () => {
);
});
});

describe("Highlight editor mustn't throw when disabled", () => {
let pages;

beforeAll(async () => {
pages = await loadAndWait(
"annotation-highlight.pdf",
".annotationEditorLayer"
);
});

afterAll(async () => {
await closePages(pages);
});

it("must enable & disable highlight mode successfully", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
const modeChangedHandle = await waitForAnnotationModeChanged(page);
await switchToHighlight(page);
await awaitPromise(modeChangedHandle);

await page.waitForSelector("#highlightParamsToolbarContainer", {
visible: true,
});
await switchToHighlight(page, /* disable */ true);
await page.waitForSelector("#highlightParamsToolbarContainer", {
visible: false,
});
})
);
});
});
});

0 comments on commit 4b906ad

Please sign in to comment.