Skip to content

fix: restore per-note header visibility state on note switch#85

Merged
j4rviscmd merged 2 commits intomainfrom
fix/header-state-restore
Mar 27, 2026
Merged

fix: restore per-note header visibility state on note switch#85
j4rviscmd merged 2 commits intomainfrom
fix/header-state-restore

Conversation

@j4rviscmd
Copy link
Copy Markdown
Owner

Summary

  • Refactored headerHidden from a single global boolean to a per-note Record<string, boolean> map (headerHiddenMap), matching the pattern used by scroll/cursor position memory
  • Added noteId parameter to useScrollDirection hook with automatic state restoration via useEffect
  • Removed imperative resetHeader() call from selectNote() in favor of reactive noteId-based restoration
  • Added one-time migration from legacy headerHidden boolean key to the new map format
  • Added mapLoadedRef guard to prevent race condition between async store load and noteId change effect
  • Added scroll-to-top fallback in useBlockScrollMemory when no saved scroll position exists for a note, fixing content appearing cut off when opening new notes from a hidden-header note

Test plan

  • Open note A, scroll down to hide header, switch to note B → header should be visible (B has no saved state)
  • Switch back to note A → header should be restored to hidden state
  • Create a new note from a note with hidden header → new note should open scrolled to top with header visible
  • Restart app → last opened note's header state should be restored correctly
  • Verify legacy headerHidden boolean is migrated and cleaned up on first launch

🤖 Generated with Claude Code

j4rviscmd and others added 2 commits March 27, 2026 23:34
Previously, headerHidden was a single global boolean that was always
reset to visible when switching notes. This caused the header open/close
state to not be restored when returning to a note where the header was
hidden. Now headerHiddenMap stores state per note (Record<noteId, boolean>),
matching the pattern used by scroll/cursor position memory.

Also adds scroll-to-top fallback when no saved scroll position exists
for a note, fixing content appearing cut off when opening new notes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@j4rviscmd j4rviscmd added the bug Something isn't working label Mar 27, 2026
@j4rviscmd j4rviscmd merged commit 7c597b9 into main Mar 27, 2026
2 checks passed
@j4rviscmd j4rviscmd deleted the fix/header-state-restore branch March 27, 2026 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant