1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #16563 from calixteman/bug1838855

Guess that a checkbox belongs to a group in using its T value (bug 1838855)
This commit is contained in:
calixteman 2023-06-16 20:40:34 +02:00 committed by GitHub
commit a5c10b6d89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 76 additions and 4 deletions

View file

@ -1530,6 +1530,17 @@ class WidgetAnnotation extends Annotation {
if (data.fieldName === undefined) {
data.fieldName = this._constructFieldName(dict);
}
if (
data.fieldName &&
/\[\d+\]$/.test(data.fieldName) &&
!dict.has("Kids")
) {
data.baseFieldName = data.fieldName.substring(
0,
data.fieldName.lastIndexOf("[")
);
}
if (data.actions === undefined) {
data.actions = collectActions(xref, dict, AnnotationActionEventType);
}

View file

@ -1674,6 +1674,11 @@ class PDFDocument {
}
}
if (!field.has("Kids") && /\[\d+\]$/.test(name)) {
// We've a terminal node: strip the index.
name = name.substring(0, name.lastIndexOf("["));
}
if (!promises.has(name)) {
promises.set(name, []);
}

View file

@ -1106,7 +1106,7 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
element.setAttribute("data-element-id", id);
element.disabled = this.data.readOnly;
element.name = this.data.fieldName;
element.name = this.data.baseFieldName || this.data.fieldName;
element.tabIndex = DEFAULT_TAB_INDEX;
this._setRequired(element, this.data.required);
@ -1408,7 +1408,7 @@ class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
element.disabled = data.readOnly;
this._setRequired(element, this.data.required);
element.type = "checkbox";
element.name = data.fieldName;
element.name = data.baseFieldName || data.fieldName;
if (value) {
element.setAttribute("checked", true);
}
@ -1493,7 +1493,7 @@ class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {
element.disabled = data.readOnly;
this._setRequired(element, this.data.required);
element.type = "radio";
element.name = data.fieldName;
element.name = data.baseFieldName || data.fieldName;
if (value) {
element.setAttribute("checked", true);
}
@ -1606,7 +1606,7 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
selectElement.disabled = this.data.readOnly;
this._setRequired(selectElement, this.data.required);
selectElement.name = this.data.fieldName;
selectElement.name = this.data.baseFieldName || this.data.fieldName;
selectElement.tabIndex = DEFAULT_TAB_INDEX;
let addAnEmptyEntry = this.data.combo && this.data.options.length > 0;