feat(useTextareaAutosize): add optional maxHeight to limit autosize growth#5324
Merged
antfu merged 6 commits intoApr 28, 2026
Merged
Conversation
maxHeight to limit autosize growth
@vueuse/components
@vueuse/core
@vueuse/electron
@vueuse/firebase
@vueuse/integrations
@vueuse/math
@vueuse/metadata
@vueuse/nuxt
@vueuse/router
@vueuse/rxjs
@vueuse/shared
@vueuse/skills
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5324 +/- ##
==========================================
+ Coverage 65.07% 65.38% +0.31%
==========================================
Files 346 346
Lines 8163 8167 +4
Branches 2514 2505 -9
==========================================
+ Hits 5312 5340 +28
+ Misses 2322 2304 -18
+ Partials 529 523 -6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
OrbisK
previously approved these changes
Apr 23, 2026
antfu
previously approved these changes
Apr 28, 2026
antfu
enabled auto-merge
April 28, 2026 05:47
9romise
approved these changes
Apr 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before submitting the PR, please make sure you do the following
fixes #123).Description
useTextareaAutosizecurrently grows the applied size to match the fullscrollHeight.This becomes problematic when using
styleProp: 'minHeight', which is the documented approach when atextareaalso usesrows. In that case, the element keeps growing indefinitely and there is no built-in way to clamp autosize growth.Using CSS
max-heightdoes not reliably solve this whenminHeightis used, because the composable continuously increases the appliedmin-heightvalue to matchscrollHeight.This PR adds an optional
maxHeightoption touseTextareaAutosize.When provided, the computed autosize value is clamped before being applied:
maxHeight, behavior remains unchangedmaxHeight, the applied size becomesMath.min(scrollHeight, maxHeight)This allows limiting textarea growth while still keeping autosize behavior.
Additional context
This change is fully backward compatible because
maxHeightis optional and existing behavior is preserved when it is not provided.