question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: Autogrow property in IonTextArea doesnt look good

See original GitHub issue

Bug Report

Ionic version:

[x] 5.1

Current behavior: When I initialize the value of a text area the label doesnt look good

Expected behavior: Need to auto expand if I set property autogrod = true

Steps to reproduce:

Set a value to textArea component

Related code:

<IonItem>
            <IonLabel position="stacked">Beneficios</IonLabel>
            <IonTextarea 
              className="inputs"
              placeholder={benefits}
              autoGrow={true}
              maxlength={400}     
              value={benefits}
              rows={6} cols={20}
              onIonChange={e => setBenefits(e.detail.value!)}>
            </IonTextarea>
 </IonItem>

Other information:

localhost_8100_home(iPhone X)

Ionic info:

Ionic:

   Ionic CLI       : 6.8.0 (/Users/timugo/.nvm/versions/node/v12.16.0/lib/node_modules/@ionic/cli)
   Ionic Framework : @ionic/react 5.1.0

Capacitor:

   Capacitor CLI   : 2.1.0
   @capacitor/core : 2.1.0

Utility:

   cordova-res : not installed
   native-run  : not installed

System:

   NodeJS : v12.16.0 (/Users/timugo/.nvm/versions/node/v12.16.0/bin/node)
   npm    : 6.14.4
   OS     : macOS Mojave

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:41 (20 by maintainers)

github_iconTop GitHub Comments

6reactions
svmszcckcommented, Dec 30, 2020

I have tried this approach until this bug is solved and it seems to be working(I am using Ionic Vue):

state.loading is false initially.

  <ion-item v-if="state.loaded">
    <ion-textarea
      placeholder="Blabla"
      class="input"
      :auto-grow="true"
      rows="5"
    ></ion-textarea>
  </ion-item>
 setTimeout(() => {
   state.loaded = true;
 }, 250);

You can decrease the timeout value but I think 250ms is acceptable.

6reactions
EinfachHanscommented, Nov 26, 2020

Working Workaround

Until this is fixed, you can use this as a good Workaround:

define in global.scss:

.some-class {
  // see: https://github.com/ionic-team/ionic-framework/issues/21242
  textarea {
    min-height: 66px;
  }
}

Of course you can adjust the value, 66px fits perfect for my case 😊 Then you need to add this class to every textarea 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ionic 4 ion-textarea autoGrow does not display properly with ...
Hello, when the ion-textarea is first displayed with text using ngModel, the autoGrow directive does not work as the height of the textarea ......
Read more >
Ionic text area value not a auto height - Stack Overflow
I'm using Ionic 3 and I' ...
Read more >
The Cleanest Trick for Autogrowing Textareas
The trick is that you exactly replicate the content of the <textarea> in an element that can auto expand height, and match its...
Read more >
HTMLTextAreaElement - Web APIs | MDN
Fires when the text selection in a <textarea> element has been changed. Examples. Autogrowing textarea example. Make a textarea autogrow while ...
Read more >
Ionic 5 autoGrow BUG - CodePen
Insecure Resource. The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found