Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,17 @@ function TextArea(props: TextAreaProps, ref: TextAreaRef) {
}
input.style.alignSelf = "start";
input.style.height = "auto";
// offsetHeight - clientHeight accounts for the border/padding.

const computedStyle = getComputedStyle(input);
const paddingTop = parseFloat(computedStyle.paddingTop);
const paddingBottom = parseFloat(computedStyle.paddingBottom);
input.style.height = `${
input.scrollHeight + (input.offsetHeight - input.clientHeight)
// subtract comptued padding and border to get the actual content height
input.scrollHeight -
paddingTop -
paddingBottom +
// Also, adding 1px to fix a bug in browser where there is a scrolllbar on certain heights
1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without +1, I see this bug

CleanShot.2024-05-31.at.16.34.35.mp4

@KelvinOm

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsartisan This works without adding 1. Please check it. It looks like the calculations were simply wrong before.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, without 1, it does not work.
I have these settings on my mac.
CleanShot 2024-06-03 at 15 23 18@2x

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.

}px`;
input.style.overflow = prevOverflow;
input.style.alignSelf = prevAlignment;
Expand Down