diff --git a/src/core/annotation.js b/src/core/annotation.js index dd5ecbb67..17b348d41 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -1630,7 +1630,8 @@ class WidgetAnnotation extends Annotation { if ( data.fieldName && /\[\d+\]$/.test(data.fieldName) && - !dict.has("Kids") + !dict.has("Kids") && + dict.has("T") ) { data.baseFieldName = data.fieldName.substring( 0, diff --git a/src/core/document.js b/src/core/document.js index 3909fea38..8f7ad958e 100644 --- a/src/core/document.js +++ b/src/core/document.js @@ -1711,7 +1711,7 @@ class PDFDocument { name = name === "" ? partName : `${name}.${partName}`; } - if (!field.has("Kids") && /\[\d+\]$/.test(name)) { + if (!field.has("Kids") && field.has("T") && /\[\d+\]$/.test(name)) { // We've a terminal node: strip the index. name = name.substring(0, name.lastIndexOf("[")); } diff --git a/test/integration/annotation_spec.js b/test/integration/annotation_spec.js index 00c0c3ccd..bacca3712 100644 --- a/test/integration/annotation_spec.js +++ b/test/integration/annotation_spec.js @@ -160,6 +160,37 @@ describe("Checkbox annotation", () => { ); }); }); + + describe("bug1847733.pdf", () => { + let pages; + + beforeAll(async () => { + pages = await loadAndWait("bug1847733.pdf", "[data-annotation-id='18R']"); + }); + + afterAll(async () => { + await closePages(pages); + }); + + it("must check the checkbox", async () => { + await Promise.all( + pages.map(async ([browserName, page]) => { + const selectors = [18, 30, 42, 54].map( + id => `[data-annotation-id='${id}R']` + ); + for (const selector of selectors) { + await page.click(selector); + page.waitForTimeout(10); + } + for (const selector of selectors) { + await page.waitForFunction( + `document.querySelector("${selector} > :first-child").checked` + ); + } + }) + ); + }); + }); }); describe("Text widget", () => { diff --git a/test/pdfs/bug1847733.pdf.link b/test/pdfs/bug1847733.pdf.link new file mode 100644 index 000000000..9bf8a2563 --- /dev/null +++ b/test/pdfs/bug1847733.pdf.link @@ -0,0 +1,2 @@ +https://github.com/mozilla/pdf.js/files/12290354/PDF.Form.4.pdf + diff --git a/test/test_manifest.json b/test/test_manifest.json index dbff94481..3ac698a71 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -8070,5 +8070,13 @@ "rounds": 1, "type": "eq", "print": true + }, + { + "id": "bug1847733", + "file": "pdfs/bug1847733.pdf", + "md5": "d2e167216493a50f732b4b3685a91792", + "rounds": 1, + "link": true, + "type": "other" } ]