Skip to content

Commit

Permalink
Merge pull request #17809 from calixteman/rotate_editor_layer
Browse files Browse the repository at this point in the history
Don't hide the editor layer when rotating (follow-up of #17802)
  • Loading branch information
calixteman authored Mar 19, 2024
2 parents e892f3b + a3873e4 commit 3718d0a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/display/editor/annotation_editor_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ class AnnotationEditorLayer {
return this.#editors.size === 0;
}

get isInvisible() {
return (
this.isEmpty && this.#uiManager.getMode() === AnnotationEditorType.NONE
);
}

/**
* Update the toolbar if it's required to reflect the tool currently used.
* @param {number} mode
Expand Down
34 changes: 34 additions & 0 deletions test/integration/freetext_editor_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3397,4 +3397,38 @@ describe("FreeText Editor", () => {
);
});
});

describe("Annotation editor layer visibility", () => {
let pages;

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

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

it("must check that the annotation layer is visible after a rotation", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await switchToFreeText(page);

for (let i = 0; i < 4; i++) {
await page.waitForSelector(
".page[data-page-number='1'] .annotationEditorLayer:not([hidden])",
{
timeout: 0,
}
);
const promise = await waitForAnnotationEditorLayer(page);
await page.evaluate(() => {
document.getElementById("pageRotateCw").click();
});
await awaitPromise(promise);
}
})
);
});
});
});
2 changes: 1 addition & 1 deletion web/annotation_editor_layer_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class AnnotationEditorLayerBuilder {
}

show() {
if (!this.div || this.annotationEditorLayer.isEmpty) {
if (!this.div || this.annotationEditorLayer.isInvisible) {
return;
}
this.div.hidden = false;
Expand Down

0 comments on commit 3718d0a

Please sign in to comment.