mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-29 04:38:55 +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) => {
|
onInput={(e) => {
|
||||||
const { scrollHeight, offsetHeight, clientHeight, value } = e.target;
|
const { scrollHeight, offsetHeight, clientHeight, value } = e.target;
|
||||||
setText(value);
|
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;
|
const offset = offsetHeight - clientHeight;
|
||||||
e.target.style.height = value ? scrollHeight + offset + 'px' : null;
|
e.target.style.height = value ? scrollHeight + offset + 'px' : null;
|
||||||
|
}
|
||||||
props.onInput?.(e);
|
props.onInput?.(e);
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
|
|
Loading…
Reference in a new issue