@@ -84,6 +84,9 @@ export abstract class Field<T = any>
8484 */
8585 DEFAULT_VALUE : T | null = null ;
8686
87+ /** Non-breaking space. */
88+ static readonly NBSP = '\u00A0' ;
89+
8790 /**
8891 * A value used to signal when a field's constructor should *not* set the
8992 * field's value or run configure_, and should allow a subclass to do that
@@ -106,7 +109,28 @@ export abstract class Field<T = any>
106109 * field is not yet initialized. Is *not* guaranteed to be accurate.
107110 */
108111 private tooltip : Tooltip . TipInfo | null = null ;
109- protected size_ : Size ;
112+
113+ /** This field's dimensions. */
114+ private size : Size = new Size ( 0 , 0 ) ;
115+
116+ /**
117+ * Gets the size of this field. Because getSize() and updateSize() have side
118+ * effects, this acts as a shim for subclasses which wish to adjust field
119+ * bounds when setting/getting the size without triggering unwanted rendering
120+ * or other side effects. Note that subclasses must override *both* get and
121+ * set if either is overridden; the implementation may just call directly
122+ * through to super, but it must exist per the JS spec.
123+ */
124+ protected get size_ ( ) : Size {
125+ return this . size ;
126+ }
127+
128+ /**
129+ * Sets the size of this field.
130+ */
131+ protected set size_ ( newValue : Size ) {
132+ this . size = newValue ;
133+ }
110134
111135 /** The rendered field's SVG group element. */
112136 protected fieldGroup_ : SVGGElement | null = null ;
@@ -969,6 +993,8 @@ export abstract class Field<T = any>
969993 // Truncate displayed string and add an ellipsis ('...').
970994 text = text . substring ( 0 , this . maxDisplayLength - 2 ) + '…' ;
971995 }
996+ // Replace whitespace with non-breaking spaces so the text doesn't collapse.
997+ text = text . replace ( / \s / g, Field . NBSP ) ;
972998 if ( this . sourceBlock_ && this . sourceBlock_ . RTL ) {
973999 // The SVG is LTR, force text to be RTL by adding an RLM.
9741000 text += '\u200F' ;
0 commit comments