fix(modals): center modals in visible content area accounting for sidebar and panel#3933
fix(modals): center modals in visible content area accounting for sidebar and panel#3933waleedlatif1 wants to merge 1 commit intostagingfrom
Conversation
PR SummaryMedium Risk Overview The workspace pre-hydration script now always sets a The Command-K search modal is refactored into group components, adds new result categories ( Reviewed by Cursor Bugbot for commit 147c89d. Configure here. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR fixes modal centering across the workspace by replacing the previous viewport-based centering with a formula that accounts for the sidebar (always) and the right panel (workflow pages only). It does this through four coordinated changes: defaulting Key changes:
Confidence Score: 5/5Safe to merge — centering math is correct, all edge cases in the blocking script are handled, and the only remaining findings are style/design suggestions. All identified issues are P2: a custom rule flag on the globals.css edit (which is justified by necessity) and a design concern about embedding Next.js routing logic inside the shared emcn component. No correctness bugs, data integrity risks, or security issues exist. apps/sim/components/emcn/components/modal/modal.tsx — contains the Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Page loads] --> B{pathname includes\n/workspace/?}
B -- No --> C[CSS default:\n--sidebar-width = 0px]
B -- Yes --> D[Blocking script runs]
D --> E{localStorage\nsidebar-state?}
E -- Yes, collapsed --> F[--sidebar-width = 51px]
E -- Yes, expanded --> G[--sidebar-width = stored width]
E -- No / error --> H[--sidebar-width = 248px]
C & F & G & H --> I[Modal opens]
I --> J{Which modal?}
J -- SearchModal --> K{isOnWorkflowPage prop}
J -- ModalContent emcn --> L{usePathname\nincludes /w/?}
K -- Yes --> M["left: calc(50% + (sidebar - panel) / 2)"]
K -- No --> N["left: calc(sidebar / 2 + 50%)"]
L -- Yes --> M
L -- No --> N
M & N --> O[translate-x: -50%\nModal visually centered\nin available area]
Reviews (1): Last reviewed commit: "fix(modals): center modals in visible co..." | Re-trigger Greptile |
| const pathname = usePathname() | ||
| const isWorkflowPage = pathname?.includes('/w/') ?? false |
There was a problem hiding this comment.
Application-specific routing logic inside a shared emcn component
usePathname and the hard-coded /w/ path string embed knowledge of the Sim URL structure into ModalContent, a component that is meant to be a generic, reusable primitive. If the workflow URL segment ever changes (e.g. renamed from /w/ to /workflow/), this condition silently breaks centering for all emcn modals without any compile-time signal.
A cleaner approach is to accept an explicit prop (mirroring what SearchModal already does with isOnWorkflowPage) and let the call site decide the layout context:
export interface ModalContentProps
extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> {
showClose?: boolean
size?: ModalSize
/** Pass true on pages that have both a sidebar and a right panel (e.g. workflow canvas). */
hasRightPanel?: boolean
}Then replace the usePathname call with:
const { className, children, showClose = true, size = 'md', hasRightPanel = false, style, ...props } = ...and use hasRightPanel in the style object instead of isWorkflowPage. This removes the Next.js and URL-structure dependency from the shared component entirely.
| */ | ||
| :root { | ||
| --sidebar-width: 248px; /* SIDEBAR_WIDTH.DEFAULT */ | ||
| --sidebar-width: 0px; /* 0 outside workspace; blocking script sets actual value on workspace pages */ |
There was a problem hiding this comment.
Editing globals.css — custom rule requires avoiding this unless absolutely necessary
The project rule is to avoid editing globals.css and move style changes to local component files instead. The --sidebar-width: 0px default is needed so modals on non-workspace pages don't shift, which is a valid reason, but it's worth confirming there is no alternative (e.g. declaring a scoped :root override in the workspace layout) before landing a change here.
If the edit is indeed the only clean option, the inline comment already added (/* 0 outside workspace; blocking script sets actual value on workspace pages */) documents intent well.
Rule Used: Avoid editing the globals.css file unless absolute... (source)
Learnt From
simstudioai/sim#367
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 147c89d. Configure here.
| ref={ref} | ||
| className={cn( | ||
| 'fixed inset-0 z-[500] bg-black/10 backdrop-blur-[2px]', | ||
| 'fixed inset-0 z-[var(--z-modal)] bg-black/10 backdrop-blur-[2px]', |
There was a problem hiding this comment.
Overlay and SModal content z-index now mismatched
Medium Severity
ModalOverlay was changed from z-[500] to z-[var(--z-modal)] (200), but SModalContent in s-modal.tsx still uses z-[500] and imports this same ModalOverlay. This creates a z-index gap: the overlay sits at 200 while the sidebar-modal content sits at 500. Elements using --z-popover (300) or --z-tooltip (400) can now visually render between the overlay and the SModal content, breaking the expected stacking order where the overlay dims everything beneath the modal.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 147c89d. Configure here.


Summary
Type of Change
Testing
Tested manually
Checklist