Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextArea's autoHeight sometimes makes it taller than an actual text #2173

Closed
WiNloSt opened this issue Oct 6, 2017 · 3 comments · Fixed by #2199
Closed

TextArea's autoHeight sometimes makes it taller than an actual text #2173

WiNloSt opened this issue Oct 6, 2017 · 3 comments · Fixed by #2199

Comments

@WiNloSt
Copy link
Contributor

WiNloSt commented Oct 6, 2017

Steps

  1. visit https://react.semantic-ui.com/addons/text-area#text-area-example-auto-height
  2. start typing or copy-pasting some very random long text.
  3. The textarea height will eventually grow higher than the content itself

Expected Result

the textarea height match the content height

Actual Result

the textarea height is more than the content height

Version

0.74.2

Browsers tested

Chrome 61.0.3163.100
FireFox 55.0.3

Explanation

I think this happen because the way we calculate height. By setting height to auto the overflow content will sit in the textarea with a scroll bar. So scrollHeight will sometimes has a value larger than the actual content height without a scroll bar. Because there could be a scenario where the appearance of the scroll bar will push some words down to a new line.

I think this will happen in an environment where the scroll bar actually take spaces in the viewport.

Testcase

https://codepen.io/WiNloSt/pen/qPxEaY

@levithomason
Copy link
Member

Oh, you're fantastic. I was boggled over this some time ago and decided a couple extra pixels would just have to do. However, simply setting overflowY = 'hidden' when height = 'auto' produces the correct scrollHeight without the extra few pixels:

image

The exact height, in this case, is 2574. This is exactly what we get when adding the already calculated borderHeight of 2px (1x top 1px bottom) back in.

A PR setting/unsetting the overflowY style would be greatly appreciated!

@WiNloSt
Copy link
Contributor Author

WiNloSt commented Oct 16, 2017

Ok, I'll work on it!

@levithomason
Copy link
Member

Released in [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants