@@ -740,6 +740,7 @@ interface MarkdownEditorProps {
740740 onKeyDown ?: ( e : React . KeyboardEvent ) => void ;
741741 placeholder ?: string ;
742742 minHeight ?: string ;
743+ maxHeight ?: string ;
743744 autoFocus ?: boolean ;
744745 disabled ?: boolean ;
745746}
@@ -770,6 +771,7 @@ export const MarkdownEditor = memo(function MarkdownEditor({
770771 onKeyDown,
771772 placeholder = "Leave a comment..." ,
772773 minHeight = "100px" ,
774+ maxHeight = "50vh" ,
773775 autoFocus = false ,
774776 disabled = false ,
775777} : MarkdownEditorProps ) {
@@ -806,6 +808,17 @@ export const MarkdownEditor = memo(function MarkdownEditor({
806808 }
807809 } , [ autoFocus ] ) ;
808810
811+ // Auto-resize textarea to fit content
812+ useEffect ( ( ) => {
813+ const textarea = textareaRef . current ;
814+ if ( ! textarea ) return ;
815+
816+ // Reset height to auto to get the correct scrollHeight
817+ textarea . style . height = "auto" ;
818+ // Set height to scrollHeight to fit content
819+ textarea . style . height = `${ textarea . scrollHeight } px` ;
820+ } , [ value ] ) ;
821+
809822 // Switch back to write mode when content is cleared externally (like after submit)
810823 const prevValueRef = useRef ( value ) ;
811824 useEffect ( ( ) => {
@@ -1370,11 +1383,11 @@ export const MarkdownEditor = memo(function MarkdownEditor({
13701383 placeholder = { placeholder }
13711384 disabled = { disabled }
13721385 className = { cn (
1373- "w-full px-3 py-2 text-sm bg-transparent resize-none focus:outline-none" ,
1386+ "w-full px-3 py-2 text-sm bg-transparent resize-vertical focus:outline-none overflow-y-auto " ,
13741387 "placeholder:text-muted-foreground" ,
13751388 disabled && "opacity-50 cursor-not-allowed"
13761389 ) }
1377- style = { { minHeight } }
1390+ style = { { minHeight, maxHeight } }
13781391 />
13791392 </ div >
13801393 < PopoverContent
@@ -1427,7 +1440,10 @@ export const MarkdownEditor = memo(function MarkdownEditor({
14271440 </ PopoverContent >
14281441 </ Popover >
14291442 ) : (
1430- < div className = "px-3 py-2 overflow-auto" style = { { minHeight } } >
1443+ < div
1444+ className = "px-3 py-2 overflow-auto"
1445+ style = { { minHeight, maxHeight } }
1446+ >
14311447 { value . trim ( ) ? (
14321448 < Markdown className = "text-sm" > { value } </ Markdown >
14331449 ) : (
0 commit comments