Skip to content

Commit

Permalink
Fix autoresize not working well in Firefox on page load
Browse files Browse the repository at this point in the history
  • Loading branch information
Ary Borenszweig committed Apr 11, 2024
1 parent a61ed6a commit 98b3483
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions lib/TextArea/V5.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ CustomElement.create({
onConnect: function () {
this._textarea = this.querySelector("textarea");
this._updateListener();

// In Firefox, for some reason, the `scrollHeight` property isn't correct
// when the component is connected. It is correct when the window loads, though,
// so we also perform a resize when that happens.
// We end up doing this in all browsers, but it's fine: the second resize is a no-op.
var self = this;
window.addEventListener("load", function () {
if (self._autoresize) {
self._resize();
}
});
},

observedAttributes: ["data-autoresize"],
Expand Down
3 changes: 2 additions & 1 deletion src/Nri/Ui/TextArea/V5.elm
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ module Nri.Ui.TextArea.V5 exposing
### Patch changes
- no longer defaults the placeholder value to the label text
- No longer defaults the placeholder value to the label text
- Adjust disabled styles
- Fix initial autoresize not working in Firefox
### Changes from V4
Expand Down

0 comments on commit 98b3483

Please sign in to comment.