Skip to content

Back from draft editor returns to the screen the user came from#204

Open
therocket-gr wants to merge 2 commits into
trunkfrom
fix/back-button-origin
Open

Back from draft editor returns to the screen the user came from#204
therocket-gr wants to merge 2 commits into
trunkfrom
fix/back-button-origin

Conversation

@therocket-gr
Copy link
Copy Markdown

Summary

Fix the back button in the draft editor so it lands on the screen the user was on when they opened the draft, instead of always dropping them into the draft's project view. Closes #201.

Before, opening a recent draft from Home, the All Drafts tab, the Done tab, or the sidebar quick-link would route back into a project the user had never navigated into. The previous handleBackFromDraftEditor hard-coded the destination to 'project' — it had no notion of "where did this draft get opened from."

Approach

`editingDraft` now carries an `origin: View` recorded at the moment the editor was opened (via a tiny `resolveDraftEditorOrigin` helper). `handleBackFromDraftEditor` restores that view, only setting `activeProjectId` when the origin is actually `'project'`.

Two existing cleanup callsites used `handleBackFromDraftEditor` as a generic "exit the editor" helper — to drill into a folder, or to preview a non-markdown file. Both have their own explicit `setActiveView('project')` immediately after, so they don't want origin-based routing. Switched them to clear the editing state inline.

Chain-through: if the user is already in the editor and opens another draft (sidebar recent, intra-project link), the new editor inherits the previous draft's origin — back never chains through the editor itself.

Test plan

  • Home → recent draft → back lands on Home.
  • Projects → project → draft → back lands on the project view.
  • All Drafts → draft → back lands on All Drafts.
  • Done → done file → back lands on Done.
  • Sidebar recent draft → back lands on whatever screen was active when the sidebar link was clicked.
  • In editor, click another sidebar recent → back lands on the original origin (not on the prior draft, not on a project view).
  • From the editor, drill into a folder still works (lands on project view).
  • From the editor, click a non-markdown preview still works (lands on project view with the preview open).

🤖 Generated with Claude Code

therocket-gr and others added 2 commits May 20, 2026 17:11
…from

Previously handleBackFromDraftEditor always routed to the draft's project
view, regardless of where the user opened the draft from. Opening a recent
draft from Home, All Drafts, the Done tab, or the sidebar quick-link would
silently drop the user into a project they never navigated into.

editingDraft now records the activeView at the moment it was opened. Back
restores that view (and only sets activeProjectId when the origin actually
was a project). The two cleanup callsites that used handleBackFromDraftEditor
specifically to "exit editor and stay in the project" now clear the editing
state inline instead, since they have their own explicit setActiveView and
no longer want origin-based routing. Opening another draft while the editor
is already open inherits the previous draft's origin so back never chains
through the editor itself. Closes #201.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds tests/e2e/back-from-editor.spec.ts covering three origins not
exercised before: Home → back → Home, Project view → back → that project,
and the chain-through case (open another draft while already in the editor
must still route back to the original origin, not loop through the editor).

Updates the pre-existing draft-editor.spec.ts case that asserted the old
behavior (opening from All Drafts and landing on the project view) to
assert the corrected behavior (landing on All Drafts).

The back button's aria-label/title was hard-coded "Back to project", which
is misleading now that back routes to wherever the user actually came from.
Both become a plain "Back".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

Improve back button consistency

1 participant