Skip to content

Commit fd3f752

Browse files
committed
[Editor] Correctly focus the annotation once the comment has been removed in the annotation layer (bug 1994738)
1 parent 745e427 commit fd3f752

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

src/display/annotation_layer.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2685,6 +2685,10 @@ class PopupElement {
26852685
this.#firstElement.commentText = this.#commentText = text;
26862686
}
26872687

2688+
focus() {
2689+
this.#firstElement.container?.focus();
2690+
}
2691+
26882692
get parentBoundingClientRect() {
26892693
return this.#firstElement.layer.getBoundingClientRect();
26902694
}

test/integration/comment_spec.mjs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,4 +798,44 @@ describe("Comment", () => {
798798
);
799799
});
800800
});
801+
802+
describe("Focus annotation after comment has been deleted (bug 1994738)", () => {
803+
let pages;
804+
805+
beforeEach(async () => {
806+
pages = await loadAndWait(
807+
"tracemonkey.pdf",
808+
".annotationEditorLayer",
809+
"page-fit",
810+
null,
811+
{ enableComment: true }
812+
);
813+
});
814+
815+
afterEach(async () => {
816+
await closePages(pages);
817+
});
818+
819+
it("must check that the annotation is focused", async () => {
820+
await Promise.all(
821+
pages.map(async ([browserName, page]) => {
822+
await switchToHighlight(page);
823+
await highlightSpan(page, 1, "Abstract");
824+
const editorSelector = getEditorSelector(0);
825+
await editComment(page, editorSelector, "Hello world!");
826+
827+
await switchToHighlight(page, /* disable = */ true);
828+
await waitAndClick(page, ".annotationLayer .annotationCommentButton");
829+
830+
const handle = await createPromise(page, resolve => {
831+
document
832+
.querySelector(".annotationLayer section.editorAnnotation")
833+
.addEventListener("focus", resolve, { once: true });
834+
});
835+
await waitAndClick(page, "button.commentPopupDelete");
836+
await awaitPromise(handle);
837+
})
838+
);
839+
});
840+
});
801841
});

0 commit comments

Comments
 (0)