When using a Form.Control element as a textarea with autoResize, it does not auto resize when the controlled value is changed.
To reproduce:
- Create a
Form.Control element like:
<Form.Control
rows={1}
as="textarea"
autoResize
value={value}
onChange={onChange}
/>
- manually enter 3 lines of text, so the text area auto resizes to fit the 3 lines
- trigger something that sets the controlled
value to an empty string
- note that the textarea remains at 3 lines high
- manually type in the textarea again
- note that the textarea immediately auto-resizes to the new content
Expected behaviour is for the autoResize to trigger when the controlled value changes as well.
A possible fix could be to add props.value to the dependencies of this effect?
|
useEffect(() => { |
|
handleResize(); |
|
}, [handleResize]); |
When using a
Form.Controlelement as atextareawithautoResize, it does not auto resize when the controlledvalueis changed.To reproduce:
Form.Controlelement like:valueto an empty stringExpected behaviour is for the autoResize to trigger when the controlled
valuechanges as well.A possible fix could be to add
props.valueto the dependencies of this effect?paragon/src/Form/FormControl.jsx
Lines 50 to 52 in d5cfe63