@@ -138,6 +138,46 @@ test.describe('TextArea', () => {
138138 await expect ( element ) . not . toHaveAttribute ( 'auto-resize' ) ;
139139 } ) ;
140140
141+ test ( 'should place the auto-sizer element inside the root element when `field-sizing: content` is not supported' , async ( {
142+ fastPage,
143+ page,
144+ } ) => {
145+ const { element } = fastPage ;
146+
147+ // Mock CSS.supports to simulate a browser that doesn't support `field-sizing: content` (e.g. Firefox)
148+ // and restore it after to avoid affecting subsequent tests
149+ await page . evaluate ( ( ) => {
150+ const originalSupports = CSS . supports . bind ( CSS ) ;
151+ ( window as Window & { __originalCSSSupports ?: typeof CSS . supports } ) . __originalCSSSupports = originalSupports ;
152+ CSS . supports = ( property : string , value ?: string ) => {
153+ if ( property === 'field-sizing: content' || ( property === 'field-sizing' && value === 'content' ) ) {
154+ return false ;
155+ }
156+ return originalSupports ( property , value as string ) ;
157+ } ;
158+ } ) ;
159+
160+ try {
161+ await fastPage . setTemplate ( { attributes : { 'auto-resize' : true } } ) ;
162+
163+ const autoSizerIsInsideRoot = await element . evaluate ( ( node : TextArea ) => {
164+ const root = node . shadowRoot ?. querySelector ( '.root' ) ;
165+ return root ?. contains ( node . autoSizerEl ?? null ) ?? false ;
166+ } ) ;
167+
168+ expect ( autoSizerIsInsideRoot ) . toBe ( true ) ;
169+ } finally {
170+ // Restore the original CSS.supports to avoid affecting other tests
171+ await page . evaluate ( ( ) => {
172+ const w = window as Window & { __originalCSSSupports ?: typeof CSS . supports } ;
173+ if ( w . __originalCSSSupports ) {
174+ CSS . supports = w . __originalCSSSupports ;
175+ delete w . __originalCSSSupports ;
176+ }
177+ } ) ;
178+ }
179+ } ) ;
180+
141181 test ( 'should toggle block attribute' , async ( { fastPage } ) => {
142182 const { element } = fastPage ;
143183
0 commit comments