File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -291,13 +291,20 @@ export default function Page() {
291291 rows = { 1 }
292292 placeholder = ""
293293 onKeyUp = { ( e ) => {
294- if ( e . key === "Enter" ) {
294+ if ( e . key === "Enter" && ! e . shiftKey ) {
295295 e . preventDefault ( )
296296 handleSubmit ( onSubmit ) ( )
297+ } else {
298+ const textarea = e . target as HTMLTextAreaElement
299+ textarea . style . height = "auto" // Reset the height to its default to allow it to shrink when deleting text
300+ textarea . style . height = `${ textarea . scrollHeight } px` // Set the height to the scroll height so that it expands on new lines
297301 }
298302 } }
299303 className = "max-h-52 h-6 overflow-y-hidden m-0 w-full resize-none border-0 bg-transparent p-0 pl-2 pr-7 focus:ring-0 focus-visible:ring-0 dark:bg-transparent md:pl-0"
300- { ...register ( "prompt" , { required : true } ) }
304+ { ...register ( "prompt" , {
305+ required : true ,
306+ disabled : streaming ,
307+ } ) }
301308 />
302309 < button
303310 type = "submit"
You can’t perform that action at this time.
0 commit comments