Skip to content

fix(settings): keep integration connect dialog drafts on backdrop click - #20932

Merged
AmethystLiang merged 2 commits into
mainfrom
jinjing/sta-7332-设置-集成,点击弹窗后再点击空空白区域弹框就会消失,会丢失之前的输入
Sep 16, 2026

Hidden character warning

The head ref may contain hidden characters: "jinjing/sta-7332-\u8bbe\u7f6e-\u96c6\u6210\uff0c\u70b9\u51fb\u5f39\u7a97\u540e\u518d\u70b9\u51fb\u7a7a\u7a7a\u767d\u533a\u57df\u5f39\u6846\u5c31\u4f1a\u6d88\u5931\uff0c\u4f1a\u4e22\u5931\u4e4b\u524d\u7684\u8f93\u5165"
Merged

AmethystLiang merged 2 commits into
mainfrom
jinjing/sta-7332-设置-集成,点击弹窗后再点击空空白区域弹框就会消失,会丢失之前的输入

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​529 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​529
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​64 $\color{#cf222e}{\Huge{\mathbf{−}}}$​13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​51

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

  1. The three DialogContents omitted onPointerDownOutside / onInteractOutside, so Radix's default modal=true dismissal fired on the backdrop click.
  2. Each dialog deliberately resets its fields on open, so close → reopen cleared the draft.

handleOpenChange only blocked while connecting; it never protected a typed draft. SshTargetForm already had the correct dirty-gated behavior.

Fix

  • New pure, dependency-free factory preventOutsideDismissWhenDirty(isDirty) (src/renderer/src/lib/outside-dismiss-guard.ts) returning an outside-dismiss handler that calls event.preventDefault() while the draft is dirty.
  • Wired into the three connect dialogs and refactored SshTargetForm onto the same factory (removes the duplicate inline guard, keeps behavior identical — the predicate reads refs at event time).
  • Escape / Cancel / × remain the explicit discard paths (matching SshTargetForm and the WAI-ARIA modal convention); only the accidental backdrop click is guarded.
  • Dirty predicates count only the fields the active auth mode submits. Bitbucket compares email/baseUrl against a props-seeded baseline ref, so a mid-edit status refresh that rewrites initial* 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

  • Factory unit — preventDefault iff dirty; predicate read at call time.
  • Component (connect-dialog-outside-dismiss.test.tsx, happy-dom, real Radix dialog) — per-field dirty keeps the draft + blocks onOpenChange; 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.
  • E2E (tests/e2e/settings-integration-dialog-dismiss.spec.ts) — Settings → Integrations, type, click the overlay, assert data-state="open" + value retained; Cancel discards and reopening is empty.

Verification

  • pnpm tc:web, pnpm exec oxlint, pnpm run check:code-quality:changed — clean.
  • Targeted renderer tests + e2e spec pass locally.

Notes

  • Pre-existing, not introduced here: SshTargetForm's host-field onBlur normalization can make an untouched edit form read dirty on the first backdrop click (configHost rewrite). Out of scope for this ticket.
  • Renderer-only: no IPC, persisted format, wire change, dependency, or cross-platform surface.

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
@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: b7895ce1-812d-480c-8b1f-8ae841d4cd5f

📥 Commits

Reviewing files that changed from the base of the PR and between 9103a1e and b6c9775.

📒 Files selected for processing (1)
  • tests/e2e/settings-integration-dialog-dismiss.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/e2e/settings-integration-dialog-dismiss.spec.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The 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 b6c97

No concrete merge-blocking risk was identified.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning 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/… 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…
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: preserving integration dialog drafts when users click the backdrop.
Full details: Description check

Explanation

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.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • New outside-dismiss guard factory — src/renderer/src/lib/outside-dismiss-guard.ts exposes preventOutsideDismissWhenDirty(isDirty), which calls event.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 clear email/apiToken, so a toggle alone leaves nothing to protect and the form still dismisses; siteUrl is intentionally retained across modes.
  • Linear predicate — apiKeyDraft !== ''.
  • Bitbucket predicate — baseUrl compared against a baselineRef seeded from the initial* 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.
  • SshTargetForm refactor — the inline guard is replaced by the factory; it still reads formRef/baselineRef at 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 SshTargetForm dirty-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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@AmethystLiang AmethystLiang changed the title fix(settings): keep integration connect dialog drafts on backdrop click (STA-7332) fix(settings): keep integration connect dialog drafts on backdrop click Sep 16, 2026
@AmethystLiang
AmethystLiang merged commit bfc297d into main Sep 16, 2026
34 checks passed
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…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
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.

1 participant