Skip to content

Commit

Permalink
Merge pull request #28 from CoenWarmer/storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
CoenWarmer authored Aug 8, 2023
2 parents 1a5fe1b + 9915344 commit 533d6d9
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ export function ChatPromptEditor({ disabled, loading, onSubmit }: ChatPromptEdit
setFunctionPayload('');
};

const handleResizeTextArea = (textarea: HTMLTextAreaElement | null) => {
if (textarea) {
textarea.style.height = 'auto';
textarea.style.height = textarea?.scrollHeight + 'px';
const handleResizeTextArea = () => {
if (textAreaRef.current) {
textAreaRef.current.style.height = 'auto';
textAreaRef.current.style.height = textAreaRef.current?.scrollHeight + 'px';
}
};

Expand All @@ -73,7 +73,7 @@ export function ChatPromptEditor({ disabled, loading, onSubmit }: ChatPromptEdit

setPrompt('');
setFunctionPayload(undefined);
handleResizeTextArea(textAreaRef.current);
handleResizeTextArea();

try {
if (selectedFunction) {
Expand Down Expand Up @@ -119,11 +119,11 @@ export function ChatPromptEditor({ disabled, loading, onSubmit }: ChatPromptEdit

if (textarea) {
textarea.focus();
textarea.addEventListener('input', () => handleResizeTextArea(textarea), false);
textarea.addEventListener('input', handleResizeTextArea, false);
}

return () => {
textarea?.removeEventListener('input', () => handleResizeTextArea(textarea), false);
textarea?.removeEventListener('input', handleResizeTextArea, false);
};
});

Expand Down

0 comments on commit 533d6d9

Please sign in to comment.