Skip to content

Admin settings: guard client-side navigation away from a dirty section #515

Open

Description

@mchestr

Follow-up from #514 (admin navigation restructure).

What happens now. Settings sections that moved onto feature pages (/admin/rewind/settings, /admin/discord/settings, /admin/ai/settings, /admin/request-limits) keep a reload/close prompt through useLeaveGuard (hooks/use-leave-guard.ts), but beforeunload does not fire on client-side navigation. Switching a section tab or a sidebar item while a section is in edit mode with unsaved changes unmounts it and the draft is gone, with no prompt. On the old one-page Settings, moving between sections kept drafts, because nothing unmounted.

Where it bites most. The Rewind settings form is large; one tap on Season or Playground mid-edit loses it. The time-zone note inside that form no longer links while editing (fixed in #514), but every tab and sidebar link is still a live exit.

Possible shapes.

  • Intercept Link clicks inside the admin shell while any useLeaveGuard(true) is registered (a small context: sections register their dirty state; SectionTabs, the sidebar and the tab bar ask before navigating, with a ConfirmDialog).
  • Or keep the draft across navigation (persist the form state per section id in sessionStorage, restore on return). Covers reload too, but is more state to reason about.
  • Next 16 has no router-level blocking API, so either way it is an app-level guard.

Scope note. The same guard would cover the Settings page's own sections (switching sidebar items while dirty), which main already dropped silently; the restructure made the exit one tab away instead of one sidebar item away.


Generated by Claude Code

Activity

  1. added
    enhancement
    admin-ui
    on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    admin-uienhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions