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
Next Next commit
fix(modals): center modals in visible content area accounting for sid…
…ebar and panel
  • Loading branch information
waleedlatif1 committed Apr 4, 2026
commit 6c80532847d4097344ae05957e40300082f7a927
2 changes: 1 addition & 1 deletion apps/sim/app/_styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @see stores/constants.ts for the source of truth
*/
:root {
--sidebar-width: 248px; /* SIDEBAR_WIDTH.DEFAULT */
--sidebar-width: 0px; /* 0 outside workspace; blocking script sets actual value on workspace pages */
Comment thread
waleedlatif1 marked this conversation as resolved.
Outdated
--panel-width: 320px; /* PANEL_WIDTH.DEFAULT */
--toolbar-triggers-height: 300px; /* TOOLBAR_TRIGGERS_HEIGHT.DEFAULT */
--editor-connections-height: 172px; /* EDITOR_CONNECTIONS_HEIGHT.DEFAULT */
Expand Down
7 changes: 6 additions & 1 deletion apps/sim/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
}

// Sidebar width
var defaultSidebarWidth = '248px';
try {
var stored = localStorage.getItem('sidebar-state');
if (stored) {
Expand All @@ -108,11 +109,15 @@ export default function RootLayout({ children }: { children: React.ReactNode })
document.documentElement.style.setProperty('--sidebar-width', width + 'px');
} else if (width > maxSidebarWidth) {
document.documentElement.style.setProperty('--sidebar-width', maxSidebarWidth + 'px');
} else {
document.documentElement.style.setProperty('--sidebar-width', defaultSidebarWidth);
}
}
} else {
document.documentElement.style.setProperty('--sidebar-width', defaultSidebarWidth);
}
} catch (e) {
// Fallback handled by CSS defaults
document.documentElement.style.setProperty('--sidebar-width', defaultSidebarWidth);
}

// Panel width and active tab
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,11 @@ export function SearchModal({
'-translate-x-1/2 fixed top-[15%] z-50 w-[500px] rounded-xl border-[4px] border-black/[0.06] bg-[var(--bg)] shadow-[0_24px_80px_-16px_rgba(0,0,0,0.15)] dark:border-white/[0.06] dark:shadow-[0_24px_80px_-16px_rgba(0,0,0,0.4)]',
open ? 'visible opacity-100' : 'invisible opacity-0'
)}
style={{ left: 'calc(var(--sidebar-width) / 2 + 50%)' }}
style={{
left: isOnWorkflowPage
? 'calc(50% + (var(--sidebar-width) - var(--panel-width)) / 2)'
: 'calc(var(--sidebar-width) / 2 + 50%)',
}}
>
<Command label='Search' shouldFilter={false}>
<div className='mx-2 mt-2 mb-1 flex items-center gap-1.5 rounded-lg border border-[var(--border-1)] bg-[var(--surface-5)] px-2 dark:bg-[var(--surface-4)]'>
Expand Down
9 changes: 7 additions & 2 deletions apps/sim/components/emcn/components/modal/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import * as React from 'react'
import * as DialogPrimitive from '@radix-ui/react-dialog'
import * as TabsPrimitive from '@radix-ui/react-tabs'
import { X } from 'lucide-react'
import { usePathname } from 'next/navigation'
import { cn } from '@/lib/core/utils/cn'
import { Button } from '../button/button'

Expand All @@ -55,7 +56,7 @@ const ANIMATION_CLASSES =
* We keep only the slide animations (no zoom) to stabilize positioning while avoiding scale effects.
*/
const CONTENT_ANIMATION_CLASSES =
'data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[50%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[50%] motion-reduce:animate-none'
'data-[state=closed]:slide-out-to-top-[50%] data-[state=open]:slide-in-from-top-[50%] motion-reduce:animate-none'

/**
* Root modal component. Manages open state.
Expand Down Expand Up @@ -145,6 +146,8 @@ const ModalContent = React.forwardRef<
ModalContentProps
>(({ className, children, showClose = true, size = 'md', style, ...props }, ref) => {
const [isInteractionReady, setIsInteractionReady] = React.useState(false)
const pathname = usePathname()
const isWorkflowPage = pathname?.includes('/w/') ?? false
Comment thread
waleedlatif1 marked this conversation as resolved.

React.useEffect(() => {
const timer = setTimeout(() => setIsInteractionReady(true), 100)
Expand All @@ -164,7 +167,9 @@ const ModalContent = React.forwardRef<
className
)}
style={{
left: '50%',
left: isWorkflowPage
? 'calc(50% + (var(--sidebar-width) - var(--panel-width)) / 2)'
: 'calc(var(--sidebar-width) / 2 + 50%)',
...style,
Comment thread
waleedlatif1 marked this conversation as resolved.
}}
onEscapeKeyDown={(e) => {
Expand Down
Loading