Skip to content

Commit

Permalink
Calculate padding bottom on textarea.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathewjordan committed Jun 26, 2024
1 parent 1a4d428 commit 0056b31
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions components/Search/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,23 @@ const SearchTextArea = forwardRef<HTMLTextAreaElement, SearchTextAreaProps>(
useEffect(() => {
const textarea = textareaRef.current;
if (textarea) {
textarea.style.height = `${textarea.scrollHeight}px`;
const height =
textarea.scrollHeight > 60
? textarea.scrollHeight + 20
: textarea.scrollHeight;
textarea.style.height = `${height}px`;
}
}, [searchValue]);

const handleChange = (e: ChangeEvent<HTMLTextAreaElement>) => {
handleSearchChange(e);
const textarea = textareaRef.current;
if (textarea) {
textarea.style.height = `${textarea.scrollHeight}px`;
const height =
textarea.scrollHeight > 60
? textarea.scrollHeight + 20
: textarea.scrollHeight;
textarea.style.height = `${height}px`;
}
};

Expand Down

0 comments on commit 0056b31

Please sign in to comment.