[JS] Hide field borders and buttons (#15053)
- Since the border belongs to the section containing the HTML counterpart of an annotation, this section must be hidden when a JS action requires it; - it wasn't possible to hide a button in using JS.
This commit is contained in:
parent
b8688128e3
commit
7e3941da9d
@ -309,7 +309,7 @@ class AnnotationElement {
|
||||
return shadow(this, "_commonActions", {
|
||||
display: event => {
|
||||
const hidden = event.detail.display % 2 === 1;
|
||||
event.target.style.visibility = hidden ? "hidden" : "visible";
|
||||
this.container.style.visibility = hidden ? "hidden" : "visible";
|
||||
this.annotationStorage.setValue(this.data.id, {
|
||||
hidden,
|
||||
print: event.detail.display === 0 || event.detail.display === 3,
|
||||
@ -321,7 +321,7 @@ class AnnotationElement {
|
||||
});
|
||||
},
|
||||
hidden: event => {
|
||||
event.target.style.visibility = event.detail.hidden
|
||||
this.container.style.visibility = event.detail.hidden
|
||||
? "hidden"
|
||||
: "visible";
|
||||
this.annotationStorage.setValue(this.data.id, {
|
||||
@ -570,6 +570,7 @@ class LinkAnnotationElement extends AnnotationElement {
|
||||
render() {
|
||||
const { data, linkService } = this;
|
||||
const link = document.createElement("a");
|
||||
link.setAttribute("id", data.id);
|
||||
let isBound = false;
|
||||
|
||||
if (data.url) {
|
||||
@ -1429,7 +1430,14 @@ class PushButtonWidgetAnnotationElement extends LinkAnnotationElement {
|
||||
container.title = this.data.alternativeText;
|
||||
}
|
||||
|
||||
this._setDefaultPropertiesFromJS(container);
|
||||
if (this.enableScripting && this.hasJSActions) {
|
||||
const linkElement = container.lastChild;
|
||||
this._setDefaultPropertiesFromJS(linkElement);
|
||||
|
||||
linkElement.addEventListener("updatefromsandbox", jsEvent => {
|
||||
this._dispatchEventFromSandbox({}, jsEvent);
|
||||
});
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
|
@ -1336,4 +1336,56 @@ describe("Interaction", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("in issue15053.pdf", () => {
|
||||
let pages;
|
||||
|
||||
beforeAll(async () => {
|
||||
pages = await loadAndWait("issue15053.pdf", "#\\34 4R");
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await closePages(pages);
|
||||
});
|
||||
|
||||
it("must check that a button and text field with a border are hidden", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
await page.waitForFunction(
|
||||
"window.PDFViewerApplication.scriptingReady === true"
|
||||
);
|
||||
|
||||
let visibility = await page.$eval(
|
||||
"[data-annotation-id='35R']",
|
||||
el => getComputedStyle(el).visibility
|
||||
);
|
||||
expect(visibility)
|
||||
.withContext(`In ${browserName}`)
|
||||
.toEqual("visible");
|
||||
|
||||
visibility = await page.$eval(
|
||||
"[data-annotation-id='51R']",
|
||||
el => getComputedStyle(el).visibility
|
||||
);
|
||||
expect(visibility)
|
||||
.withContext(`In ${browserName}`)
|
||||
.toEqual("visible");
|
||||
|
||||
await page.click("#\\34 4R");
|
||||
|
||||
visibility = await page.$eval(
|
||||
"[data-annotation-id='35R']",
|
||||
el => getComputedStyle(el).visibility
|
||||
);
|
||||
expect(visibility).withContext(`In ${browserName}`).toEqual("hidden");
|
||||
|
||||
visibility = await page.$eval(
|
||||
"[data-annotation-id='51R']",
|
||||
el => getComputedStyle(el).visibility
|
||||
);
|
||||
expect(visibility).withContext(`In ${browserName}`).toEqual("hidden");
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -527,3 +527,4 @@
|
||||
!issue14705.pdf
|
||||
!bug1771477.pdf
|
||||
!bug1724918.pdf
|
||||
!issue15053.pdf
|
||||
|
BIN
test/pdfs/issue15053.pdf
Executable file
BIN
test/pdfs/issue15053.pdf
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user