Skip to content

Commit 8188c87

Browse files
authored
Merge pull request #20572 from calixteman/issue20571
Avoid exception after having moved an annotation
2 parents f04deee + 8abfd9a commit 8188c87

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

src/display/editor/editor.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,9 @@ class AnnotationEditor {
12041204
}
12051205

12061206
get comment() {
1207+
if (!this.#comment) {
1208+
return null;
1209+
}
12071210
const {
12081211
data: { richText, text, date, deleted },
12091212
} = this.#comment;

test/integration/freetext_editor_spec.mjs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3645,4 +3645,46 @@ describe("FreeText Editor", () => {
36453645
);
36463646
});
36473647
});
3648+
3649+
describe("No exception when moving (issue 20571)", () => {
3650+
let pages;
3651+
3652+
beforeEach(async () => {
3653+
pages = await loadAndWait(
3654+
"tracemonkey.pdf",
3655+
".annotationEditorLayer",
3656+
100
3657+
);
3658+
});
3659+
3660+
afterEach(async () => {
3661+
await closePages(pages);
3662+
});
3663+
3664+
it("must check that the buttons work correctly", async () => {
3665+
await Promise.all(
3666+
pages.map(async ([browserName, page]) => {
3667+
await switchToFreeText(page);
3668+
3669+
const rect = await getRect(page, ".annotationEditorLayer");
3670+
await createFreeTextEditor({
3671+
page,
3672+
x: rect.x + 100,
3673+
y: rect.y + 100,
3674+
data: "Hello PDF.js World !!",
3675+
});
3676+
3677+
await switchToFreeText(page, /* disable = */ true);
3678+
await switchToFreeText(page);
3679+
3680+
const editorSelector = getEditorSelector(0);
3681+
await selectEditor(page, editorSelector);
3682+
await dragAndDrop(page, editorSelector, [[10, 10]]);
3683+
3684+
await switchToFreeText(page, /* disable = */ true);
3685+
await switchToFreeText(page);
3686+
})
3687+
);
3688+
});
3689+
});
36483690
});

0 commit comments

Comments
 (0)