From cb1638530d83707bb772cdc15d80517a7cdfff0f Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Thu, 9 Feb 2023 18:30:31 +0100 Subject: [PATCH] [Annotation] A combo can have a value other than one in the options When printing the pdf in #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. --- src/core/annotation.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/core/annotation.js b/src/core/annotation.js index add90e7c6e74e..1c3490f2b9f32 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -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 === "") {