Fix autoresize not working well in Firefox on page load

This commit is contained in:
Ary Borenszweig 2024-04-11 16:09:59 -03:00
parent a61ed6a1de
commit 98b348325a
2 changed files with 13 additions and 1 deletions

View File

@ -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"],

View File

@ -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