diff --git a/src/components/PromptLibraryMenu/PromptLibraryMenu.tsx b/src/components/PromptLibraryMenu/PromptLibraryMenu.tsx index 77fa31f..568c431 100644 --- a/src/components/PromptLibraryMenu/PromptLibraryMenu.tsx +++ b/src/components/PromptLibraryMenu/PromptLibraryMenu.tsx @@ -39,6 +39,7 @@ const PromptLibraryMenuPopUp = ({ const handleInput = (e: React.ChangeEvent) => { e.target.style.height = 'auto'; e.target.style.height = `${e.target.scrollHeight}px`; + e.target.style.maxHeight = `${e.target.scrollHeight}px`; }; const handleSave = () => { @@ -62,13 +63,16 @@ const PromptLibraryMenuPopUp = ({ _setPrompts(updatedPrompts); }; - useEffect(() => { - if (container && container.current) { - container.current.querySelectorAll('textarea').forEach((elem) => { - elem.style.height = `${elem.scrollHeight}px`; - }); - } - }, []); + const handleOnFocus = (e: React.FocusEvent) => { + e.target.style.height = 'auto'; + e.target.style.height = `${e.target.scrollHeight}px`; + e.target.style.maxHeight = `${e.target.scrollHeight}px`; + }; + + const handleOnBlur = (e: React.FocusEvent) => { + e.target.style.height = 'auto'; + e.target.style.maxHeight = '2.5rem'; + }; return (
-
{t('name')}
+
{t('name')}
{t('prompt')}
{_prompts.map((prompt, index) => ( @@ -87,9 +91,11 @@ const PromptLibraryMenuPopUp = ({ key={prompt.id} className='flex items-center border-b border-gray-500/50 mb-1 p-1' > -
+