Merge pull request #16035 from calixteman/fix_combo_value

[Annotation] A combo can have a value other than one in the options
This commit is contained in:
calixteman 2023-02-09 19:56:16 +01:00 committed by GitHub
commit 0fca6e187c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1981,15 +1981,14 @@ class WidgetAnnotation extends Annotation {
} }
assert(typeof value === "string", "Expected `value` to be a string."); assert(typeof value === "string", "Expected `value` to be a string.");
if (!this.data.combo) {
value = value.trim(); value = value.trim();
} else {
// The value is supposed to be one of the exportValue. if (this.data.combo) {
const option = // The value can be one of the exportValue or any other values.
this.data.options.find(({ exportValue }) => value === exportValue) || const option = this.data.options.find(
this.data.options[0]; ({ exportValue }) => value === exportValue
value = (option && option.displayValue) || ""; );
value = (option && option.displayValue) || value;
} }
if (value === "") { if (value === "") {