@@ -10,6 +10,7 @@ import { live } from 'lit/directives/live.js';
1010import { type StyleInfo , styleMap } from 'lit/directives/style-map.js' ;
1111
1212import { getThemeController , themes } from '../../theming/theming-decorator.js' ;
13+ import { createResizeController } from '../common/controllers/resize-observer.js' ;
1314import { watch } from '../common/decorators/watch.js' ;
1415import { registerComponent } from '../common/definitions/register.js' ;
1516import type { Constructor } from '../common/mixins/constructor.js' ;
@@ -83,7 +84,7 @@ export default class IgcTextareaComponent extends FormAssociatedRequiredMixin(
8384 public static styles = [ styles , shared ] ;
8485
8586 /* blazorSuppress */
86- public static register ( ) {
87+ public static register ( ) : void {
8788 registerComponent ( IgcTextareaComponent , IgcValidationContainerComponent ) ;
8889 }
8990
@@ -102,8 +103,6 @@ export default class IgcTextareaComponent extends FormAssociatedRequiredMixin(
102103
103104 protected inputId = `textarea-${ IgcTextareaComponent . increment ( ) } ` ;
104105
105- private observer ! : ResizeObserver ;
106-
107106 @queryAssignedNodes ( { flatten : true } )
108107 private projected ! : Array < Node > ;
109108
@@ -298,29 +297,18 @@ export default class IgcTextareaComponent extends FormAssociatedRequiredMixin(
298297 constructor ( ) {
299298 super ( ) ;
300299
300+ createResizeController ( this , {
301+ callback : this . setAreaHeight ,
302+ } ) ;
303+
301304 this . _formValue = createFormValueState ( this , { initialValue : '' } ) ;
302305
303306 this . addEventListener ( 'focus' , this . handleFocus ) ;
304307 this . addEventListener ( 'blur' , this . handleBlur ) ;
305308 }
306309
307- public override async connectedCallback ( ) {
308- super . connectedCallback ( ) ;
309-
310- await this . updateComplete ;
311-
312- this . setAreaHeight ( ) ;
313- this . observer = new ResizeObserver ( ( ) => this . setAreaHeight ( ) ) ;
314- this . observer . observe ( this . input ) ;
315- }
316-
317- public override disconnectedCallback ( ) : void {
318- this . observer . disconnect ( ) ;
319- super . disconnectedCallback ( ) ;
320- }
321-
322310 /** Selects all text within the control. */
323- public select ( ) {
311+ public select ( ) : void {
324312 this . input . select ( ) ;
325313 }
326314
@@ -329,7 +317,7 @@ export default class IgcTextareaComponent extends FormAssociatedRequiredMixin(
329317 start : number ,
330318 end : number ,
331319 direction : SelectionRangeDirection = 'none'
332- ) {
320+ ) : void {
333321 this . input . setSelectionRange ( start , end , direction ) ;
334322 }
335323
@@ -339,7 +327,7 @@ export default class IgcTextareaComponent extends FormAssociatedRequiredMixin(
339327 start : number ,
340328 end : number ,
341329 selectMode : RangeTextSelectMode = 'preserve'
342- ) {
330+ ) : void {
343331 this . input . setRangeText ( replacement , start , end , selectMode ) ;
344332 this . value = this . input . value ;
345333 }
@@ -349,7 +337,7 @@ export default class IgcTextareaComponent extends FormAssociatedRequiredMixin(
349337 /* blazorSuppress */
350338 public override scrollTo ( x : number , y : number ) : void ;
351339 public override scrollTo ( x ?: unknown , y ?: unknown ) : void {
352- x !== undefined && y !== undefined
340+ x != null && y != null
353341 ? this . input . scrollTo ( x as number , y as number )
354342 : this . input . scrollTo ( x as ScrollToOptions ) ;
355343 }
0 commit comments