Skip to content

fix(ui): restore settings dialog focus - #1883

Merged
Soju06 merged 2 commits into
Soju06:mainfrom
mastertyko:fix/settings-dialog-focus-restore
Aug 26, 2026
Merged

fix(ui): restore settings dialog focus#1883
Soju06 merged 2 commits into
Soju06:mainfrom
mastertyko:fix/settings-dialog-focus-restore

Conversation

@mastertyko

@mastertyko mastertyko commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Restore keyboard focus to the exact Settings button that opened the View collected data or Set password dialog. Both controlled dialogs now register their real invoker through Radix DialogTrigger, matching the existing trigger-backed focus behavior instead of leaving document.activeElement on body.

Type of change

  • fix: — bug fix (no behavior change beyond the bug)
  • feat: — new user-facing feature or capability
  • refactor: — internal refactor (no behavior change, no API change)
  • docs: — documentation only
  • chore: / ci: / build: — tooling, CI, packaging
  • test: — test-only change
  • Breaking change

Linked issue: None — independently reproduced; the bounded issue and PR overlap checks found no relevant work or prerequisite.

OpenSpec

  • This PR includes / updates an OpenSpec change
  • Not applicable — bug fix that matches the existing spec
  • Not applicable — docs / CI / chore only
  • This PR touches a codex-faithful path

Change directory: openspec/changes/restore-settings-dialog-focus/

Changes

  • Register View collected data as the telemetry preview dialog trigger while keeping the preview fetch conditional on the dialog being open.
  • Render Set password through the password setup dialog trigger while retaining activeDialog as the controlled password-dialog state.
  • Cover Escape and explicit Close/Cancel for both flows, including exact invoker focus and document.body exclusion.
  • Leave shared dialog primitives plus password change/remove/verify and TOTP flows unchanged.

Simplicity

No new setting, default, setup step, dependency, README section, dashboard navigation item, or shared focus abstraction. The fix reuses the existing Radix trigger mechanism.

Test plan

  • bun run test -- src/features/settings/components/telemetry-settings.test.tsx src/features/settings/components/password-settings.test.tsx — 2 files, 21 tests passed. The four new cases failed on the dispatched baseline with body focused, then passed after the fix.
  • bun node_modules/eslint/bin/eslint.js src/features/settings/components/telemetry-settings.tsx src/features/settings/components/telemetry-settings.test.tsx src/features/settings/components/password-settings.tsx src/features/settings/components/password-settings.test.tsx src/features/settings/components/password-setup-dialog.tsx — passed.
  • bun run typecheck — passed.
  • openspec validate restore-settings-dialog-focus --type change --strict — passed.
  • OpenSpec verification — 9/9 tasks complete; the requirement and all four scenarios map to implementation plus focused Vitest/browser evidence; no critical, warning, or coherence findings.
  • git diff --check — passed.

Known baseline-only validation debt: openspec validate frontend-architecture --type spec --strict still reports the two unchanged existing conversation requirements whose first paragraph lacks a normative keyword. This branch does not edit openspec/specs/frontend-architecture/spec.md; the scoped change validates strictly.

Not run locally: full local CI, full frontend suite, or coverage. The focused Standard-risk checks above cover this seam; required GitHub CI remains the integration gate.

Screenshots / output

This focus-only fix has no static visual delta, so equivalent observable Chromium evidence is more accurate than screenshots. Against an isolated empty local backend, each flow was exercised before and after at a nonzero Settings scroll position:

Flow Dismissal Baseline document.activeElement Fixed document.activeElement Scroll before → after
View collected data Escape BODY BUTTON — View collected data 1735 → 1735
View collected data Close BODY BUTTON — View collected data 1735 → 1735
Set password Escape BODY BUTTON — Set password 982 → 982
Set password Cancel BODY BUTTON — Set password 982 → 982

The telemetry preview still loaded its real envelope, and password Cancel/Escape submitted no setup request.

Checklist

  • Title is in Conventional Commits format.
  • Related issue/PR overlap checked; no relevant public work exists to link.
  • Added tests covering the changed behavior.
  • Ran the relevant focused lint, test, typecheck, and browser subsets locally.
  • Scoped strict OpenSpec validation passes and OpenSpec verification is clean.
  • Simplicity gates reviewed.
  • CHANGELOG.md is not edited by hand.

Summary by CodeRabbit

  • Bug Fixes
    • Restored keyboard focus to the exact button that opened the Settings dialogs after dismissal.
    • Improved focus behavior when closing the telemetry preview or password setup dialogs with Escape, Close, or Cancel.
    • Prevented focus from incorrectly moving to the document body.
    • Ensured dismissing the password setup dialog does not trigger a password submission.

@mastertyko

Copy link
Copy Markdown
Contributor Author

@codex review

@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fceb7e26-1fdf-434a-a085-6c0731bbd84d

📥 Commits

Reviewing files that changed from the base of the PR and between d4b00fd and d9ffac4.

📒 Files selected for processing (10)
  • frontend/src/features/settings/components/password-settings.test.tsx
  • frontend/src/features/settings/components/password-settings.tsx
  • frontend/src/features/settings/components/password-setup-dialog.tsx
  • frontend/src/features/settings/components/telemetry-settings.test.tsx
  • frontend/src/features/settings/components/telemetry-settings.tsx
  • openspec/changes/restore-settings-dialog-focus/.openspec.yaml
  • openspec/changes/restore-settings-dialog-focus/design.md
  • openspec/changes/restore-settings-dialog-focus/proposal.md
  • openspec/changes/restore-settings-dialog-focus/specs/frontend-architecture/spec.md
  • openspec/changes/restore-settings-dialog-focus/tasks.md

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


📝 Walkthrough

Walkthrough

The Settings password setup and telemetry preview dialogs now use their invoking buttons as DialogTrigger elements. Tests verify focus restoration after Escape or explicit dismissal without password submission or body focus.

Changes

Settings dialog focus restoration

Layer / File(s) Summary
Focus restoration contract
openspec/changes/restore-settings-dialog-focus/*
The OpenSpec change defines focus restoration requirements, preserved dialog behavior, regression scenarios, and completed validation tasks.
Password setup trigger flow
frontend/src/features/settings/components/password-setup-dialog.tsx, frontend/src/features/settings/components/password-settings.tsx, frontend/src/features/settings/components/password-settings.test.tsx
PasswordSetupDialog accepts trigger content through DialogTrigger. Password settings controls the dialog state through trigger changes. Tests cover Escape and Cancel dismissal, focus restoration, and no password request.
Telemetry preview trigger flow
frontend/src/features/settings/components/telemetry-settings.tsx, frontend/src/features/settings/components/telemetry-settings.test.tsx
The telemetry preview button uses DialogTrigger. Tests cover Escape and Close dismissal and focus restoration to the preview button.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to d9ffa

This localized fix restores keyboard focus to the Settings button that opened each dialog without changing the surrounding flows. No actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: soju06

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 5 files. (5 skipped: 5 unsupported.) Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: restoring focus in Settings dialogs.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: d9ffac4980

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Komzpa Komzpa added 🤖 codex: ok [@codex review] says no issues found. and removed 🤖 codex: ok [@codex review] says no issues found. labels Aug 22, 2026
@Soju06
Soju06 merged commit 5dc49e9 into Soju06:main Aug 26, 2026
59 of 64 checks passed
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.

3 participants