Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix focus in emcn modal
  • Loading branch information
TheodoreSpeaks committed Apr 13, 2026
commit 3630d04bd2703fab7177c4885e29746d30f3808d
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ export function ScheduleModal({ open, onOpenChange, workspaceId, schedule }: Sch
}}
placeholder='e.g., Daily report generation'
className='h-9'
autoFocus
autoComplete='off'
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ export function BYOK() {
}}
placeholder={PROVIDERS.find((p) => p.id === editingProvider)?.placeholder}
className='h-9 pr-9'
autoFocus
name='byok_api_key'
autoComplete='off'
autoCorrect='off'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ export function Copilot() {
}}
placeholder='e.g., Development, Production'
className='h-9'
autoFocus
/>
{createError && (
<p className='text-[var(--text-error)] text-small leading-tight'>{createError}</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export function InboxEnableToggle() {
onChange={(e) => setEnableUsername(e.target.value)}
placeholder='e.g., acme'
className='h-9'
autoFocus
/>
<p className='text-[var(--text-muted)] text-caption'>
Leave blank for an auto-generated address.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ export function InboxSettingsTab() {
}}
placeholder='user@example.com'
className='h-9'
autoFocus
/>
</div>
<div className='flex flex-col gap-1'>
Expand Down Expand Up @@ -304,7 +303,6 @@ export function InboxSettingsTab() {
}}
placeholder='e.g., new-acme'
className='h-9'
autoFocus
/>
{editAddressError && (
<p className='text-[var(--text-error)] text-small leading-tight'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,6 @@ export function IntegrationsManager() {
value={serviceSearch}
onChange={(e) => setServiceSearch(e.target.value)}
className='h-auto flex-1 border-0 bg-transparent p-0 font-base leading-none placeholder:text-[var(--text-tertiary)] focus-visible:ring-0 focus-visible:ring-offset-0'
autoFocus
/>
</div>
<div className='flex max-h-[320px] flex-col overflow-y-auto'>
Expand Down Expand Up @@ -916,7 +915,6 @@ export function IntegrationsManager() {
autoComplete='off'
data-lpignore='true'
className='mt-1.5'
autoFocus
Comment thread
TheodoreSpeaks marked this conversation as resolved.
/>
</div>
<div>
Expand Down Expand Up @@ -1053,7 +1051,6 @@ export function IntegrationsManager() {
'min-h-[120px] resize-none border-0 font-mono text-[12px]',
saDragActive && 'opacity-30'
)}
autoFocus
/>
</div>
<div className='mt-1.5'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,6 @@ export function McpDeploy({
Description
</Label>
<Textarea
autoFocus
placeholder='Describe what this tool does...'
className='min-h-[100px] resize-none'
value={toolDescription}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,6 @@ export function InviteModal({ open, onOpenChange, workspaceName }: InviteModalPr
: 'Enter emails'
}
placeholderWithTags='Add email'
autoFocus={userPerms.canAdmin}
disabled={isSubmitting || !userPerms.canAdmin}
fileInputOptions={fileInputOptions}
/>
Expand Down
6 changes: 3 additions & 3 deletions apps/sim/components/emcn/components/modal/auto-focus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export function focusFirstTextInput(event: Event): void {
const content = event.currentTarget as HTMLElement | null
if (!content) return

const target = Array.from(
content.querySelectorAll<HTMLElement>(TEXT_INPUT_SELECTOR)
).find(isVisible)
const target = Array.from(content.querySelectorAll<HTMLElement>(TEXT_INPUT_SELECTOR)).find(
isVisible
)
if (!target) return

event.preventDefault()
Expand Down
107 changes: 56 additions & 51 deletions apps/sim/components/emcn/components/modal/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,59 +138,64 @@ export interface ModalContentProps
const ModalContent = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Content>,
ModalContentProps
>(({ className, children, showClose = true, size = 'md', style, onOpenAutoFocus, ...props }, ref) => {
const [isInteractionReady, setIsInteractionReady] = React.useState(false)
const pathname = usePathname()
const isWorkflowPage = pathname?.includes('/w/') ?? false

React.useEffect(() => {
const timer = setTimeout(() => setIsInteractionReady(true), 100)
return () => clearTimeout(timer)
}, [])

return (
<ModalPortal>
<ModalOverlay />
<div
className='pointer-events-none fixed inset-0 z-[var(--z-modal)] flex items-center justify-center'
style={{
paddingLeft: isWorkflowPage
? 'calc(var(--sidebar-width) - var(--panel-width))'
: 'var(--sidebar-width)',
}}
>
<DialogPrimitive.Content
ref={ref}
className={cn(
'pointer-events-auto flex max-h-[84vh] flex-col overflow-hidden rounded-xl bg-[var(--bg)] text-small ring-1 ring-foreground/10',
ANIMATION_CLASSES,
'data-[state=open]:zoom-in-95 data-[state=closed]:zoom-out-95 duration-200',
MODAL_SIZES[size],
className
)}
style={style}
onEscapeKeyDown={(e) => {
if (!isInteractionReady) {
e.preventDefault()
return
}
e.stopPropagation()
}}
onPointerDown={(e) => {
e.stopPropagation()
>(
(
{ className, children, showClose = true, size = 'md', style, onOpenAutoFocus, ...props },
ref
) => {
const [isInteractionReady, setIsInteractionReady] = React.useState(false)
const pathname = usePathname()
const isWorkflowPage = pathname?.includes('/w/') ?? false

React.useEffect(() => {
const timer = setTimeout(() => setIsInteractionReady(true), 100)
return () => clearTimeout(timer)
}, [])

return (
<ModalPortal>
<ModalOverlay />
<div
className='pointer-events-none fixed inset-0 z-[var(--z-modal)] flex items-center justify-center'
style={{
paddingLeft: isWorkflowPage
? 'calc(var(--sidebar-width) - var(--panel-width))'
: 'var(--sidebar-width)',
}}
onPointerUp={(e) => {
e.stopPropagation()
}}
onOpenAutoFocus={onOpenAutoFocus ?? focusFirstTextInput}
{...props}
>
{children}
</DialogPrimitive.Content>
</div>
</ModalPortal>
)
})
<DialogPrimitive.Content
ref={ref}
className={cn(
'pointer-events-auto flex max-h-[84vh] flex-col overflow-hidden rounded-xl bg-[var(--bg)] text-small ring-1 ring-foreground/10',
ANIMATION_CLASSES,
'data-[state=open]:zoom-in-95 data-[state=closed]:zoom-out-95 duration-200',
MODAL_SIZES[size],
className
)}
style={style}
onEscapeKeyDown={(e) => {
if (!isInteractionReady) {
e.preventDefault()
return
}
e.stopPropagation()
}}
onPointerDown={(e) => {
e.stopPropagation()
}}
onPointerUp={(e) => {
e.stopPropagation()
}}
onOpenAutoFocus={onOpenAutoFocus ?? focusFirstTextInput}
{...props}
>
{children}
</DialogPrimitive.Content>
</div>
</ModalPortal>
)
}
)

ModalContent.displayName = 'ModalContent'

Expand Down
Loading