Skip to content

Commit

Permalink
[Annotation] A combo can have a value other than one in the options
Browse files Browse the repository at this point in the history
When printing the pdf in mozilla#12233 in Acrobat, we can see that the combo for country
is empty: it's because the V entry doesn't have to be one of the options.
  • Loading branch information
calixteman committed Feb 9, 2023
1 parent 533a461 commit cb16385
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/core/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1981,15 +1981,14 @@ class WidgetAnnotation extends Annotation {
}

assert(typeof value === "string", "Expected `value` to be a string.");
value = value.trim();

if (!this.data.combo) {
value = value.trim();
} else {
// The value is supposed to be one of the exportValue.
const option =
this.data.options.find(({ exportValue }) => value === exportValue) ||
this.data.options[0];
value = (option && option.displayValue) || "";
if (this.data.combo) {
// The value can be one of the exportValue or any other values.
const option = this.data.options.find(
({ exportValue }) => value === exportValue
);
value = (option && option.displayValue) || value;
}

if (value === "") {
Expand Down

0 comments on commit cb16385

Please sign in to comment.