Fix: Inconsistent Textarea resizing in small width windows #3006
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.
Addresses a bug causing inconsistent resizing of the send message textarea when the window width is small, and preventing it from returning to its minimum height after sending a message.
Problem:
The original textarea resizing logic relied on
scrollHeightto determine the necessary height. However, this approach failed to account for how changes in window width affected the text wrapping and subsequentscrollHeightcalculation. After sending a message and clearing the textarea's content, thescrollHeightoften retained a value larger than the actual minimum height, preventing the textarea from shrinking as expected. This was particularly noticeable at smaller widths where text wrapping significantly impactsscrollHeight.Solution:
This PR resolves the issue by explicitly resetting the textarea height to
1pxbefore recalculatingscrollHeight. This ensures that the browser computes the height based on the currently visible text as not doing so could lead to potentially caching stalescrolHeightafter content cleared. The new calculation, using onlysendTextArea.scrollHeight, is simpler and more accurate.This change provides more reliable and consistent resizing behavior, ensuring the textarea shrinks correctly to its minimum height after sending a message, regardless of window width changes or previous text wrapping states.
Tests:
Before:
Excuse the potato quality as I can't upload more than 10MB. Just notice the size of the text area, here's a picture to show the px height:

textarea_width_bug_480p.mp4
After:
Chrome:
textarea_width_fix.mp4
Firefox:
textarea_width_fix_firefox.mp4
Checklist: