@@ -180,9 +180,11 @@ export function LinkModal({ documentId, isOpen, onClose, onExited, source }: Lin
180180
181181 const canSubmit = activeTab === 'page' || url . trim ( ) . length > 0 ;
182182
183- const handleFormSubmit = ( e : Event ) => {
184- e . preventDefault ( ) ;
185- handleSubmit ( ) ;
183+ const handleInputKeyDown = ( e : h . JSX . TargetedKeyboardEvent < HTMLInputElement > ) => {
184+ if ( e . key === 'Enter' && canSubmit ) {
185+ e . preventDefault ( ) ;
186+ handleSubmit ( ) ;
187+ }
186188 } ;
187189
188190 return (
@@ -193,7 +195,7 @@ export function LinkModal({ documentId, isOpen, onClose, onExited, source }: Lin
193195 onExited = { onExited }
194196 className = "md:w-[28rem]"
195197 >
196- < form onSubmit = { handleFormSubmit } className = "space-y-6" >
198+ < div className = "space-y-6" >
197199 { /* Tab buttons */ }
198200 < div className = "border-border-subtle flex border-b" >
199201 < TabButton active = { activeTab === 'url' } onClick = { ( ) => setActiveTab ( 'url' ) } >
@@ -215,6 +217,7 @@ export function LinkModal({ documentId, isOpen, onClose, onExited, source }: Lin
215217 type = "url"
216218 value = { url }
217219 onInput = { ( e ) => setUrl ( ( e . target as HTMLInputElement ) . value ) }
220+ onKeyDown = { handleInputKeyDown }
218221 placeholder = "https://example.com"
219222 className = "border-border-default bg-bg-input text-fg-primary focus:border-accent focus:ring-accent w-full rounded-md border px-3 py-2 text-base focus:outline-none focus:ring-1"
220223 autoFocus
@@ -234,6 +237,7 @@ export function LinkModal({ documentId, isOpen, onClose, onExited, source }: Lin
234237 const val = parseInt ( ( e . target as HTMLInputElement ) . value , 10 ) ;
235238 if ( ! isNaN ( val ) ) setPageNumber ( Math . max ( 1 , Math . min ( totalPages , val ) ) ) ;
236239 } }
240+ onKeyDown = { handleInputKeyDown }
237241 className = "border-border-default bg-bg-input text-fg-primary focus:border-accent focus:ring-accent w-full rounded-md border px-3 py-2 text-base focus:outline-none focus:ring-1"
238242 autoFocus
239243 />
@@ -255,14 +259,15 @@ export function LinkModal({ documentId, isOpen, onClose, onExited, source }: Lin
255259 { translate ( 'common.cancel' ) || 'Cancel' }
256260 </ Button >
257261 < Button
258- type = "submit"
262+ type = "button"
263+ onClick = { handleSubmit }
259264 disabled = { ! canSubmit }
260265 className = "bg-accent text-fg-on-accent hover:!bg-accent-hover rounded-md border border-transparent px-4 py-2 text-sm disabled:cursor-not-allowed disabled:opacity-50"
261266 >
262267 { translate ( 'link.link' ) || 'Link' }
263268 </ Button >
264269 </ div >
265- </ form >
270+ </ div >
266271 </ Dialog >
267272 ) ;
268273}
0 commit comments