From 0ff522bc9e74ea5faf2e794ad50abfa9bcb686bf Mon Sep 17 00:00:00 2001 From: Valentin Serra Date: Wed, 31 Jan 2024 10:12:48 +0100 Subject: [PATCH] fix: resize textarea on input changes Closes #1011 --- .../src/render/components/form-fields/Textarea.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/form-js-viewer/src/render/components/form-fields/Textarea.js b/packages/form-js-viewer/src/render/components/form-fields/Textarea.js index 19819d8ca..204d6215b 100644 --- a/packages/form-js-viewer/src/render/components/form-fields/Textarea.js +++ b/packages/form-js-viewer/src/render/components/form-fields/Textarea.js @@ -33,7 +33,7 @@ export function Textarea(props) { const { required } = validate; const textareaRef = useRef(); - const [ onInputChange, flushOnChange ] = useFlushDebounce(({ target }) => { + const [ onChange, flushOnChange ] = useFlushDebounce(({ target }) => { props.onChange({ field, value: target.value @@ -49,6 +49,11 @@ export function Textarea(props) { onFocus && onFocus(); }; + const onInputChange = (event) => { + onChange({ target: event.target }); + autoSizeTextarea(textareaRef.current); + }; + useLayoutEffect(() => { autoSizeTextarea(textareaRef.current); }, [ value ]);