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.

Allow TextareaAutosize to use min-height instead of height

See original GitHub issue

I want the textarea to always contain the text, but I also want it to be able to grow since it’s in a flex container.

Right now 'height' is hardcoded into the library:

https://github.com/Andarist/react-textarea-autosize/blob/0d7ac21f1dadf1fb9070aea5f76f20b7ce2f24bc/src/index.tsx#L81

I just want to be able to change this to min-height

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
LoganDarkcommented, Jul 27, 2021

I have fixed this issue in a fork and no longer need upstream approval.

I hope you at least realize @Andarist that expecting this library to get layout right in all cases is not sustainable and will inevitably result in edge cases such as this one. I would highly recommend moving to min-height (and max-height if maxRows is specified) rather than expecting height to be completely infallible. Thank you for considering my issue and I am sorry that I was not able to provide enough detail.

Here is screenshot proof of your library getting the height blatantly wrong, and exactly why min-height > height for this case:

image

I tested this exact same HTML structure (a couple nested flexboxes) in codesandbox here and your library works there, but not in my app. No idea why. No time to debug.

0reactions
Andaristcommented, Jul 26, 2021

What you can do is try to bisect the issue to demonstrate it, in an isolated form, on the codesandbox. I don’t believe in providing more options without knowing the full context behind it. If it doesn’t work in your app then is a reason for that and it should be found first and then evaluated. I’m not necessarily saying that the proposed solution is wrong but until a repro case is found I can’t see the full picture that is needed for me to justify making any changes here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature request initialHeight or minHeight #314 - GitHub
I'm setting the initialHeight or minHeight with minRows={2} but it's not exactly. There is a possibility to add an initial height.
Read more >
Creating a textarea with auto-resize - javascript - Stack Overflow
height, is holding it open. You could instead take a max() of scrollHeight and a minimum height value you have predefined or calculated...
Read more >
Textarea Autosize React component - Material UI - MUI
The Textarea Autosize component gives you a textarea HTML element that automatically adjusts its height to match the length of the content within....
Read more >
Auto-Growing Inputs & Textareas | CSS-Tricks
For textareas, one classic technique is to count the number of line-breaks, use that to set the height, then multiply it by the...
Read more >
Make a Textarea Auto Resize to fit Contents - Impressive Webs
Apply the height of the clone to the height of the textarea. The Code for Textarea Auto Resize. One of the keys to...
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