'Ionic-angular ion-textarea's height shrink

I'm coding with ionic-angular framework for some project. When I use ion-textarea, sometimes the textarea's height is decreased 0px. If the textarea code like that,

<ion-textarea class="translated"
  [value]="text">
</ion-textarea>
  • nomal state

enter image description here

  • shrink state

enter image description here

In shrink state case, the height of ion-textarea is normal but the div and textarea in the ion-textarea get somemthing wrong.

enter image description here

I want to know what is the cause of this situation and how to solve!!

please let me know what is the problem (I tested it in chrome browser)



Solution 1:[1]

<ion-textarea class="translated ion-padding"
rows='3'
</ion-textarea>

Solution 2:[2]

bad but works:

@ViewChild(IonTextarea, {static: false}) ionTextarea: IonTextarea;

async ngAfterViewInit(): Promise<void> {
  await this.checkTextarea();
}

async checkTextarea() {
 return this.ionTextarea.getInputElement().then((element) => {
  if (element.style.height == '0px') {
    return element.style.height = 'auto';
  } else {
    setTimeout(() => this.checkTextarea(), 100)
  }
  
 })
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Zrelli Majdi
Solution 2