Merge pull request #20342 from calixteman/bug1992987
[Editor] Make sure that comment stuff is removed when an editor is deleted (bug 1992987)
This commit is contained in:
commit
1df2ee68b7
@ -1899,6 +1899,7 @@ class AnnotationEditor {
|
||||
} else {
|
||||
this._uiManager.removeEditor(this);
|
||||
}
|
||||
this.hideCommentPopup();
|
||||
|
||||
if (this.#moveInDOMTimeout) {
|
||||
clearTimeout(this.#moveInDOMTimeout);
|
||||
@ -1915,6 +1916,8 @@ class AnnotationEditor {
|
||||
this.parent = null;
|
||||
this.#touchManager?.destroy();
|
||||
this.#touchManager = null;
|
||||
this.#fakeAnnotation?.remove();
|
||||
this.#fakeAnnotation = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2166,12 +2169,12 @@ class AnnotationEditor {
|
||||
}
|
||||
this._editToolbar?.hide();
|
||||
this.#altText?.toggleAltTextBadge(true);
|
||||
this.hideCommentPopup();
|
||||
}
|
||||
|
||||
hideCommentPopup() {
|
||||
if (this.hasComment) {
|
||||
this._uiManager.toggleComment(
|
||||
this,
|
||||
/* isSelected = */ false,
|
||||
/* visibility = */ false
|
||||
);
|
||||
this._uiManager.toggleComment(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -373,6 +373,36 @@ describe("Comment", () => {
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it("must check that the button is removed in the annotation layer", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([, page]) => {
|
||||
await switchToHighlight(page);
|
||||
|
||||
await highlightSpan(page, 1, "Abstract");
|
||||
const editorSelector = getEditorSelector(0);
|
||||
await editComment(page, editorSelector, "Hello world!");
|
||||
|
||||
await switchToHighlight(page, /* disable = */ true);
|
||||
const buttonSelector = ".annotationLayer .annotationCommentButton";
|
||||
await page.waitForSelector(buttonSelector, {
|
||||
visible: true,
|
||||
});
|
||||
|
||||
await switchToHighlight(page);
|
||||
await selectEditor(page, editorSelector);
|
||||
await waitAndClick(page, `${editorSelector} button.deleteButton`);
|
||||
await waitForSerialized(page, 0);
|
||||
|
||||
await switchToHighlight(page, /* disable = */ true);
|
||||
await page.waitForFunction(
|
||||
sel => !document.querySelector(sel),
|
||||
{},
|
||||
buttonSelector
|
||||
);
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Focused element after editing", () => {
|
||||
@ -624,4 +654,50 @@ describe("Comment", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Comment popup", () => {
|
||||
let pages;
|
||||
|
||||
beforeEach(async () => {
|
||||
pages = await loadAndWait(
|
||||
"tracemonkey.pdf",
|
||||
".annotationEditorLayer",
|
||||
"page-width",
|
||||
null,
|
||||
{ enableComment: true }
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await closePages(pages);
|
||||
});
|
||||
|
||||
it("must check that the popup is deleted when the editor is", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([, page]) => {
|
||||
await switchToHighlight(page);
|
||||
|
||||
await highlightSpan(page, 1, "Abstract");
|
||||
const editorSelector = getEditorSelector(0);
|
||||
await editComment(page, editorSelector, "Hello world!");
|
||||
|
||||
await waitAndClick(
|
||||
page,
|
||||
`${editorSelector} button.annotationCommentButton`
|
||||
);
|
||||
|
||||
const popupSelector = "#commentPopup";
|
||||
await page.waitForSelector(popupSelector, { visible: true });
|
||||
await waitAndClick(page, `${editorSelector} button.deleteButton`);
|
||||
|
||||
// Check that the popup is removed from the DOM.
|
||||
await page.waitForFunction(
|
||||
sel => !document.querySelector(sel),
|
||||
{},
|
||||
popupSelector
|
||||
);
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user