@@ -2139,10 +2139,18 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
21392139 }
21402140 } ) ;
21412141
2142+ const fixDisplayValue = ( option , value ) => {
2143+ const newValue = value . replaceAll ( " " , "\u00A0" ) ;
2144+ option . textContent = newValue ;
2145+ if ( newValue !== value ) {
2146+ option . setAttribute ( "display-value" , value ) ;
2147+ }
2148+ } ;
2149+
21422150 // Insert the options into the choice field.
21432151 for ( const option of this . data . options ) {
21442152 const optionElement = document . createElement ( "option" ) ;
2145- optionElement . textContent = option . displayValue ;
2153+ fixDisplayValue ( optionElement , option . displayValue ) ;
21462154 optionElement . value = option . exportValue ;
21472155 if ( storedData . value . includes ( option . exportValue ) ) {
21482156 optionElement . setAttribute ( "selected" , true ) ;
@@ -2185,7 +2193,8 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
21852193 const getItems = event => {
21862194 const options = event . target . options ;
21872195 return Array . prototype . map . call ( options , option => ( {
2188- displayValue : option . textContent ,
2196+ displayValue :
2197+ option . getAttribute ( "display-value" ) || option . textContent ,
21892198 exportValue : option . value ,
21902199 } ) ) ;
21912200 } ;
@@ -2239,7 +2248,7 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
22392248 const { index, displayValue, exportValue } = event . detail . insert ;
22402249 const selectChild = selectElement . children [ index ] ;
22412250 const optionElement = document . createElement ( "option" ) ;
2242- optionElement . textContent = displayValue ;
2251+ fixDisplayValue ( optionElement , displayValue ) ;
22432252 optionElement . value = exportValue ;
22442253
22452254 if ( selectChild ) {
@@ -2261,7 +2270,7 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
22612270 for ( const item of items ) {
22622271 const { displayValue, exportValue } = item ;
22632272 const optionElement = document . createElement ( "option" ) ;
2264- optionElement . textContent = displayValue ;
2273+ fixDisplayValue ( optionElement , displayValue ) ;
22652274 optionElement . value = exportValue ;
22662275 selectElement . append ( optionElement ) ;
22672276 }
0 commit comments