Merge pull request #20572 from calixteman/issue20571

Avoid exception after having moved an annotation
This commit is contained in:
calixteman 2026-01-18 21:06:50 +01:00 committed by GitHub
commit 8188c87461
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 45 additions and 0 deletions

View File

@ -1204,6 +1204,9 @@ class AnnotationEditor {
}
get comment() {
if (!this.#comment) {
return null;
}
const {
data: { richText, text, date, deleted },
} = this.#comment;

View File

@ -3645,4 +3645,46 @@ describe("FreeText Editor", () => {
);
});
});
describe("No exception when moving (issue 20571)", () => {
let pages;
beforeEach(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
".annotationEditorLayer",
100
);
});
afterEach(async () => {
await closePages(pages);
});
it("must check that the buttons work correctly", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await switchToFreeText(page);
const rect = await getRect(page, ".annotationEditorLayer");
await createFreeTextEditor({
page,
x: rect.x + 100,
y: rect.y + 100,
data: "Hello PDF.js World !!",
});
await switchToFreeText(page, /* disable = */ true);
await switchToFreeText(page);
const editorSelector = getEditorSelector(0);
await selectEditor(page, editorSelector);
await dragAndDrop(page, editorSelector, [[10, 10]]);
await switchToFreeText(page, /* disable = */ true);
await switchToFreeText(page);
})
);
});
});
});