mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-25 10:45:41 +03:00
Fix weird textarea height on first render
This commit is contained in:
parent
33698c91cc
commit
2d94f229c3
1 changed files with 6 additions and 2 deletions
|
@ -1370,8 +1370,12 @@ const Textarea = forwardRef((props, ref) => {
|
|||
onInput={(e) => {
|
||||
const { scrollHeight, offsetHeight, clientHeight, value } = e.target;
|
||||
setText(value);
|
||||
if (offsetHeight < window.innerHeight) {
|
||||
// NOTE: This check is needed because the offsetHeight return 50000 (really large number) on first render
|
||||
// No idea why it does that, will re-investigate in far future
|
||||
const offset = offsetHeight - clientHeight;
|
||||
e.target.style.height = value ? scrollHeight + offset + 'px' : null;
|
||||
}
|
||||
props.onInput?.(e);
|
||||
}}
|
||||
style={{
|
||||
|
|
Loading…
Reference in a new issue