diff --git a/.changeset/loud-boats-judge.md b/.changeset/loud-boats-judge.md new file mode 100644 index 00000000..9e918184 --- /dev/null +++ b/.changeset/loud-boats-judge.md @@ -0,0 +1,5 @@ +--- +'react-textarea-autosize': patch +--- + +Workaround for Firefox `scrollHeight` bug affecting textarea's height on a dynamic toggle diff --git a/src/calculateNodeHeight.ts b/src/calculateNodeHeight.ts index 3f7067eb..834e43d6 100644 --- a/src/calculateNodeHeight.ts +++ b/src/calculateNodeHeight.ts @@ -49,6 +49,9 @@ export default function calculateNodeHeight( hiddenTextarea.value = value; let height = getHeight(hiddenTextarea, sizingData); + // Double set and calc due to Firefox bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1795904 + hiddenTextarea.value = value; + height = getHeight(hiddenTextarea, sizingData); // measure height of a textarea with a single row hiddenTextarea.value = 'x';