Repository navigation
Conversation
…palette (#439) The guard only handled closing the tab and clicks on links, so pressing browser Back or jumping to a page with Ctrl/Cmd+K left a dirty form and lost the draft. - A capture-phase popstate listener on window runs before Next's router. When history moves to another page while the form is dirty it stops the router from rendering that page and asks "Leave without saving?". Keep editing puts the form's entry back on top of history; Leave page re-dispatches the popstate so the router renders the page the browser moved to. Popstates that stay on the page (section hashes) pass through untouched. - New lib/navigation-guard.ts holds the active guard. The command palette asks confirmNavigation() before router.push, so it gets the same dialog. Saving still navigates with router.push directly and never prompts. - Unit tests for the guard registry and same-page check; manual case added to the UI test plan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #439.
Summary
The guard only handled closing the tab and clicks on links, so pressing browser
Back or jumping to a page with Ctrl/Cmd+K left a dirty form and lost the draft.
history moves to another page while the form is dirty it stops the router
from rendering that page and asks "Leave without saving?". Keep editing puts
the form's entry back on top of history; Leave page re-dispatches the
popstate so the router renders the page the browser moved to. Popstates that
stay on the page (section hashes) pass through untouched.
confirmNavigation() before router.push, so it gets the same dialog. Saving
still navigates with router.push directly and never prompts.
the UI test plan.
Testing
pnpm --filter @orbit/web typecheck: passedpnpm --filter @orbit/web test: 99 passed (5 new inlib/navigation-guard.test.ts)pnpm docs:check: passeddocs/development/ui-test-plan.mdNot checked in a browser: it relies on the capture-phase listener running before Next's popstate handler and on Next 16 accepting the restored entry. After Keep editing on Back, Forward history is gone, so Forward does nothing rather than prompting.
🤖 Generated with Claude Code