Skip to content

fix: page mode toggle no longer overwrites default preference - #1996

Merged
Philipinho merged 2 commits into
docmost:mainfrom
julien-f:fix/editor-default-read-mode
May 14, 2026
Merged

Philipinho merged 2 commits into
docmost:mainfrom
julien-f:fix/editor-default-read-mode

Conversation

@julien-f

@julien-f julien-f commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1693

The header edit/read toggle was calling updateUser on every change, which overwrote the user's saved "Default page edit mode" preference. This meant navigating to any new page would inherit the last-used mode, making the preference setting ineffective.

What changed

  • Header toggle (PageEditModeToggle) now updates only a session-local Jotai atom (currentPageEditModeAtom) without persisting to the server. A new component was introduced for this, leaving the existing PageStateSegmentedControl (used in profile settings) unchanged.
  • Editors (PageEditor, TitleEditor) now react to currentPageEditModeAtom instead of reading the preference directly.
  • On first load, the user's saved preference is applied once to currentPageEditModeAtom via a module-level flag in FullEditor, so it survives component unmount/remount across page navigations.

Resulting behaviour

Scenario Before After
Open app with preference = "Read" Opens in Edit if last session was Edit Opens in Read ✓
Navigate to another page Mode resets to last-used (overwrites preference) Mode sticks from session start ✓
Toggle mode in header Saves to server, affects all future pages Local to session only ✓
Change preference in profile settings Takes effect immediately Takes effect on next app load ✓

⚠️ Note on this PR

This code was written by an AI assistant (Claude) and tested by a human, but has not been reviewed by an experienced developer. Please review carefully before merging, especially:

  • The module-level defaultEditModeApplied flag in full-editor.tsx and its implications in edge cases (SSR, HMR, multiple tabs)
  • Whether the new PageEditModeToggle component belongs in page-state-pref.tsx or should live elsewhere
  • Whether the profile setting description ("Default page edit mode") should be updated to clarify it applies on next load

Test plan

  • Set "Default page edit mode" to Read in profile settings, reload app → first page opens in Read
  • Toggle to Edit via header on page A, navigate to page B → still in Edit
  • Toggle to Read via header on page A, navigate to page B → still in Read
  • Verify profile settings control still saves preference to server
  • Reload app → preference is re-applied from saved setting

🤖 Written by Claude Code, tested by a human

Yundi339 added a commit to Yundi339/docmost that referenced this pull request Apr 22, 2026
Upstream PR docmost#1996. Introduces a currentPageEditModeAtom that tracks
the editor's mode for the current session. The header toggle updates
this atom locally without persisting to the user profile, so clicking
Edit/Read in the header no longer mutates the user's default page
edit mode preference. The user's saved preference is still applied
once per app session on first load via FullEditor.
@julien-f

Copy link
Copy Markdown
Contributor Author

@Philipinho Accidental edits happen often at my company and this change could really help.

How can I help moving it forward? 🙂

The header edit/read toggle now controls only the current session's mode
without saving it as the user's preference. The saved preference (set in
profile settings) is applied once on initial load and sticks across page
navigations within the session, so navigating to a new page no longer
resets the mode mid-session.

Fixes docmost#1693

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@julien-f
julien-f force-pushed the fix/editor-default-read-mode branch from 7981bef to a671160 Compare May 11, 2026 15:04
@Philipinho

Copy link
Copy Markdown
Member

Will revisit this.

@Philipinho
Philipinho merged commit 82d0656 into docmost:main May 14, 2026
1 check passed
Yundi339 pushed a commit to Yundi339/docmost that referenced this pull request Jun 18, 2026
…t#1996)

The header edit/read toggle now controls only the current session's mode
without saving it as the user's preference. The saved preference (set in
profile settings) is applied once on initial load and sticks across page
navigations within the session, so navigating to a new page no longer
resets the mode mid-session.

Fixes docmost#1693

(cherry picked from commit 82d0656)
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.

[BUG] "Default page edit mode" not working correctly

2 participants