Repository navigation
fix(settings): keep integration connect dialog drafts on backdrop click - #20932
Hidden character warning
Conversation
A backdrop click in the Settings → Integrations Jira/Linear/Bitbucket connect dialogs dismissed the Radix modal, and each dialog's reset-on-open then wiped the typed credential. Generalize SshTargetForm's dirty-gated outside dismissal into a shared preventOutsideDismissWhenDirty factory and wire it into the three dialogs (and SshTargetForm), so an accidental backdrop click no longer discards a draft while Escape / Cancel / × remain the explicit discard paths. Bitbucket compares email/baseUrl against a props-seeded baseline and only counts the active auth mode's fields, so a mid-edit status refresh and a mode toggle cannot make the form sticky. STA-7332
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change adds a shared outside-dismiss guard that checks draft state when an outside event occurs. Jira, Linear, Bitbucket, and SSH target forms use the guard. Bitbucket tracks open-time baseline values and active authentication mode. New unit, component, and end-to-end tests cover dirty drafts, clean forms, refreshed values, mode changes, Escape, and explicit cancellation. Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to No concrete merge-blocking risk was identified. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description clearly explains the problem, root cause, fix, scope, tests, and verification. However, it omits required template information, including a linked issue, visual proof or an explicit N/A explanation, checklist status, and the agent skill boundary section. Resolution Add the linked issue after "Fixes #"; add before-and-after visual proof or write "N/A" with a reason; complete the Testing, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections, including the required checkbox status.
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- New outside-dismiss guard factory —
src/renderer/src/lib/outside-dismiss-guard.tsexposespreventOutsideDismissWhenDirty(isDirty), which callsevent.preventDefault()only when the predicate is dirty at event time. The structural{ preventDefault }event type keeps the module dependency-free, and the JSDoc correctly warns not to memoize the handler. - Jira, Linear, and Bitbucket connect dialogs — each wires the factory into
onPointerDownOutside+onInteractOutside. Escape / Cancel / × remain the explicit discard paths, so only the accidental backdrop click is guarded. - Jira predicate —
siteUrl !== '' || email !== '' || apiToken !== ''. Mode switches clearemail/apiToken, so a toggle alone leaves nothing to protect and the form still dismisses;siteUrlis intentionally retained across modes. - Linear predicate —
apiKeyDraft !== ''. - Bitbucket predicate —
baseUrlcompared against abaselineRefseeded from theinitial*props on open, and the token-vs-basic branch counts only the active mode's fields. This keeps an untouched prefilled edit clean and prevents a mid-edit metadata refresh from flipping clean↔dirty or a stale basic-mode email from making token mode sticky. SshTargetFormrefactor — the inline guard is replaced by the factory; it still readsformRef/baselineRefat event time, so behavior is unchanged.- Tests — factory unit, happy-dom component tests against a real Radix dialog (per-field dirty blocks dismissal; clean form and mode-toggle-only dismiss as non-vacuity controls; Escape discards; prefill-baseline and mid-edit-refresh cases), an added
SshTargetFormdirty-backdrop test, and a Jira/Linear e2e spec. Assertions are exact (not.toHaveBeenCalled()/toHaveBeenCalledWith(false)), and the clean-path controls prove the dismissal mechanism still fires, so the dirty-path assertions are not vacuous.
I ran the three changed source test files (32 passed) and pnpm tc:web (clean). The change is renderer-only with no IPC, wire, persistence, or cross-platform surface.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…ck (stablyai#20932) * fix(settings): keep integration connect dialog drafts on backdrop click A backdrop click in the Settings → Integrations Jira/Linear/Bitbucket connect dialogs dismissed the Radix modal, and each dialog's reset-on-open then wiped the typed credential. Generalize SshTargetForm's dirty-gated outside dismissal into a shared preventOutsideDismissWhenDirty factory and wire it into the three dialogs (and SshTargetForm), so an accidental backdrop click no longer discards a draft while Escape / Cancel / × remain the explicit discard paths. Bitbucket compares email/baseUrl against a props-seeded baseline and only counts the active auth mode's fields, so a mid-edit status refresh and a mode toggle cannot make the form sticky. STA-7332 * test(e2e): drop ticket id from dismiss spec comment

What
In Settings → Integrations, clicking the modal backdrop closed the Jira / Linear / Bitbucket connect dialogs, and each dialog's reset-on-open then wiped the typed credential. A stray click cost the whole draft.
Root cause
DialogContents omittedonPointerDownOutside/onInteractOutside, so Radix's defaultmodal=truedismissal fired on the backdrop click.handleOpenChangeonly blocked whileconnecting; it never protected a typed draft.SshTargetFormalready had the correct dirty-gated behavior.Fix
preventOutsideDismissWhenDirty(isDirty)(src/renderer/src/lib/outside-dismiss-guard.ts) returning an outside-dismiss handler that callsevent.preventDefault()while the draft is dirty.SshTargetFormonto the same factory (removes the duplicate inline guard, keeps behavior identical — the predicate reads refs at event time).SshTargetFormand the WAI-ARIA modal convention); only the accidental backdrop click is guarded.email/baseUrlagainst a props-seeded baseline ref, so a mid-edit status refresh that rewritesinitial*can't flip clean↔dirty, and a stale basic-mode email can't make token mode sticky.Fixing the shared dialogs also fixes every other consumer (onboarding
IntegrationsStep,TaskSourceLinearSetup/TaskSourceSimpleSetup,LinearAgentSkillPane, task-page connect wrappers).Tests
preventDefaultiff dirty; predicate read at call time.connect-dialog-outside-dismiss.test.tsx, happy-dom, real Radix dialog) — per-field dirty keeps the draft + blocksonOpenChange; clean form is the non-vacuity control (it still dismisses); Escape-while-dirty discards; mode-toggle-only still dismisses; Bitbucket untouched-prefilled edit and mid-edit metadata refresh stay clean, while a typed draft survives the refresh. Falsified: reverting the guard fails the dirty tests; reverting the mode-aware predicate fails the token-mode test.tests/e2e/settings-integration-dialog-dismiss.spec.ts) — Settings → Integrations, type, click the overlay, assertdata-state="open"+ value retained; Cancel discards and reopening is empty.Verification
pnpm tc:web,pnpm exec oxlint,pnpm run check:code-quality:changed— clean.Notes
SshTargetForm's host-fieldonBlurnormalization can make an untouched edit form read dirty on the first backdrop click (configHostrewrite). Out of scope for this ticket.