Skip to content

Commit c16b40a

Browse files
authored
Fix Textarea autosize respecting rows() while preserving Firefox scroll anchoring fix (#18864)
* Fix Textarea autosize causing scroll anchoring issues in Firefox Signed-off-by: Mark Hartman <[email protected]> * Recompiled textarea.js --------- Signed-off-by: Mark Hartman <[email protected]>
1 parent d730c4a commit c16b40a

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

packages/forms/dist/components/textarea.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/forms/resources/js/components/textarea.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,18 @@ export default function textareaFormComponent({
3131
},
3232

3333
resize() {
34-
this.setInitialHeight()
35-
3634
if (this.$el.scrollHeight <= 0) {
3735
return
3836
}
3937

40-
const newHeight = this.$el.scrollHeight + 'px'
38+
const previousHeight = this.$el.style.height
39+
this.$el.style.height = '0px'
40+
41+
const contentHeight = this.$el.scrollHeight
42+
this.$el.style.height = previousHeight
43+
44+
const minHeightPx = parseFloat(initialHeight) * parseFloat(getComputedStyle(document.documentElement).fontSize)
45+
const newHeight = Math.max(contentHeight, minHeightPx) + 'px'
4146

4247
if (this.wrapperEl.style.height === newHeight) {
4348
return

0 commit comments

Comments
 (0)