Skip to content

Commit

Permalink
Workaround for Firefox bug with scrollHeight (#353)
Browse files Browse the repository at this point in the history
* fix: workaround for Firefox bug with scrollHeight

See #313

* chore: add changeset

* Update .changeset/loud-boats-judge.md

---------

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
  • Loading branch information
knownasilya and Andarist authored Mar 21, 2023
1 parent 2301195 commit 19aead9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/loud-boats-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'react-textarea-autosize': patch
---

Workaround for Firefox `scrollHeight` bug affecting textarea's height on a dynamic toggle
3 changes: 3 additions & 0 deletions src/calculateNodeHeight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 19aead9

Please sign in to comment.