Skip to content

fix: keep the scroll position when saving a note - #195

Merged
polyrainbow merged 2 commits into
mainfrom
fix/keep-scroll-on-save
Oct 16, 2026
Merged

polyrainbow merged 2 commits into
mainfrom
fix/keep-scroll-on-save

Conversation

@polyrainbow

Copy link
Copy Markdown
Owner

Saving a note (Cmd-S or the save button) scrolled the editor to the top. There were two causes:

  • First save of a new note, and a save that renames a note (any window width): Note.tsx reset the note's scroll position on every slug change. It now resets only when the slug changes along with the editor instance, which is what opening another note does (load, new, duplicate, import).
  • Every save in a window narrower than 1281px, where the note list is hidden and the document scrolls: the save navigates to the note's URL, and the Navigation API scrolls to the top after an intercepted push or replace. The save now passes keepScrollPosition in the navigation's info, and the router uses scroll: "manual" for it. Other navigations, including back/forward scroll restoration, are unchanged.

The first commit fixes a test problem found along the way: KEY_COMBINATIONS.SAVE sent Meta+S on macOS, but the "Desktop Chrome" device reports a Windows platform, so the app ignored it. "editor should keep focus after saving with key combination" passed without saving. It now checks that the note was saved.

Tests

  • Two new integration tests, one per cause. The first also checks that duplicating a note still opens it at the top. Both fail without the fix.
  • npm run lint, npm run build, npm run test and all 65 integration tests pass.

🤖 Generated with Claude Code

polyrainbow and others added 2 commits October 16, 2026 10:36
The "Desktop Chrome" device reports a Windows platform, and the app
picks the save shortcut's modifier from that platform, so Meta+S never
saved on macOS. The focus-after-save test passed without saving; it now
also checks that the note was saved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Saving scrolled the editor to the top in two cases:

- The first save of a new note, and a save that renames a note: the
  note's scroll position was reset on every slug change. It is now
  reset only when the slug changes along with the editor instance,
  i.e. when another note is opened.
- Every save in a window too narrow for the note list, where the
  document scrolls: the save navigates to the note's URL, and the
  Navigation API scrolls to the top after an intercepted replace. The
  save now asks the router for manual scrolling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@polyrainbow
polyrainbow merged commit 7a40eea into main Oct 16, 2026
6 checks passed
@polyrainbow
polyrainbow deleted the fix/keep-scroll-on-save branch October 16, 2026 08:41
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