fix(desktop): stop new-project modal from closing on open#4192
Conversation
The Add Repository dropdown's closing pointerup was racing the
NewProjectModal's Dialog and firing onPointerDownOutside before the
modal had a chance to settle, dismissing it instantly. The shared
Dialog wrapper defaults to modal={false}, so any outside pointer event
closes the dialog.
Pass modal to NewProjectModal so the overlay catches the stray event,
and add onCloseAutoFocus={preventDefault} on the dropdown content to
prevent focus from snapping back to the trigger as the dialog opens.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR refines UI component focus and modal behavior across the dashboard. NewProjectModal's Dialog now includes the ChangesDialog Modal Configuration
Dropdown Menu Focus Management
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Greptile SummaryThis PR fixes a race condition where the "Create new project" dialog would immediately close after opening because the dropdown's closing
Confidence Score: 5/5Safe to merge — two small, targeted changes that fix a real UX regression with no side effects on other flows. Both changes are minimal and well-scoped. The No files require special attention.
|
| Filename | Overview |
|---|---|
| apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/AddRepositoryModals/components/NewProjectModal/NewProjectModal.tsx | Adds modal prop to the Dialog root to enable Radix's blocking overlay and fix the race condition with the dropdown's closing pointer event. |
| apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarHeader/DashboardSidebarHeader.tsx | Adds onCloseAutoFocus prevention to both dropdown content instances (collapsed and expanded variants) to prevent focus returning to the trigger when the dialog opens. |
Sequence Diagram
sequenceDiagram
participant User
participant Dropdown as DropdownMenu
participant Store as add-repository-modal store
participant Modal as NewProjectModal (Dialog)
Note over Dropdown,Modal: Before fix — race condition
User->>Dropdown: click "Create new project"
Dropdown->>Store: openNewProject()
Dropdown-->>Dropdown: closes (fires pointerup)
Store-->>Modal: "open=true → Dialog mounts (modal=false)"
Dropdown->>Modal: pointerup bubbles → onPointerDownOutside
Modal-->>Store: handleOpenChange(false) — dialog closes instantly
Note over Dropdown,Modal: After fix
User->>Dropdown: click "Create new project"
Dropdown->>Store: openNewProject()
Dropdown-->>Dropdown: closes, onCloseAutoFocus prevented
Store-->>Modal: "open=true → Dialog mounts (modal=true)"
Note over Modal: Radix overlay blocks all outside pointer events
Modal-->>Modal: stays open ✓
User->>Modal: click overlay / Escape / Cancel
Modal-->>Store: handleOpenChange(false) — dialog closes normally
Reviews (1): Last reviewed commit: "fix(desktop): stop new-project modal fro..." | Re-trigger Greptile
Summary
onPointerDownOutsideon it.Dialogwrapper (packages/ui/src/components/ui/dialog.tsx) defaults tomodal={false}, so any outside pointer event dismisses it. PassmodalonNewProjectModalso Radix renders an overlay that catches the stray pointerup; outside-click-to-close still works via the dimmed overlay.onCloseAutoFocus={(e) => e.preventDefault()}on the dropdown content (matchesDashboardSidebarWorkspaceContextMenu.tsx:83,DashboardSidebarSectionContextMenu.tsx:25, etc.) so focus doesn't snap back to the trigger as the dialog opens.Test plan
Summary by cubic
Fixes the “Create new project” modal closing immediately when opened from the Add repository dropdown in the v2 sidebar. The modal now stays open; clicking the overlay or pressing Escape still closes it.
modalon theDialoginNewProjectModalso the overlay absorbs the dropdown’s trailing pointerup.onCloseAutoFocus={(e) => e.preventDefault()}toDropdownMenuContent(both sidebar variants) to avoid focus snapping back to the trigger.Written for commit ef30a76. Summary will update on new commits.
Summary by CodeRabbit