Skip to content

fix(web): keep modal open when a drag releases outside the dialog (#222) - #223

Open
CPPavithra wants to merge 2 commits into
guidewire-oss:mainfrom
CPPavithra:fix/project-dialog-disappears
Open

fix(web): keep modal open when a drag releases outside the dialog (#222)#223
CPPavithra wants to merge 2 commits into
guidewire-oss:mainfrom
CPPavithra:fix/project-dialog-disappears

Conversation

@CPPavithra

@CPPavithra CPPavithra commented Aug 15, 2026

Copy link
Copy Markdown

Fixes #222 — the New Project dialog closes if you select the name and release the mouse outside the dialog.

The issue: The backdrop dismissed on onClick={onClose}, and the panel guarded itself with stopPropagation. That guard can't work: a click fires on the common ancestor of its mousedown and mouseup targets, so a drag from inside the dialog to the backdrop produces a click targeting the backdrop, and the event never passes through the panel.

The fix: Dismissal now keys off mousedown/mouseup and closes only when both ends land on the backdrop. The panel's stopPropagation became dead code and was removed. onMouseUp also needed an e.button !== 0 guard as mouseup fires for every button, so a right-click would otherwise dismiss the dialog.

Tests: New Modal.test.tsx covers seven gestures. Two fail on main - the drag-out case from the issue and its mirror (press backdrop → release inside). The right-click case passes on main and guards against the regression the fix itself could introduce.

Also verified by hand: reproduced on main, confirmed fixed here


Summary by cubic

Keeps the modal open when a drag starts inside the dialog and releases on the backdrop (#222). Previously the backdrop closed on click; now it closes only when both mousedown and mouseup land on the backdrop with a left-click, and we clear the pending press on non-primary mouseup to avoid stray dismissals.

  • web-v2/src/components/ui/Modal.tsx: Replace backdrop onClick with onMouseDown/onMouseUp, track the press start target, guard with button === 0, and clear the tracked press on any mouseup so right-clicks never trigger a later close.
  • web-v2/src/components/ui/Modal.test.tsx: New tests cover seven pointer gestures; drag-out and its mirror fail on main and pass here; right-click is ignored and does not dismiss.
  • Dist asset hashes updated from a rebuild; no functional changes outside the modal.

Rollout / QA

  • Escape still dismisses. Genuine backdrop clicks still dismiss. No migrations required.

Written for commit b0bca60. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 91 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread web-v2/src/components/ui/Modal.tsx Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New Project dialog disappears if you select the name and release the mouse button off the dialog.

1 participant