Olivier Lambert f6a8247c48 fix: cursor jumps to end of text when editing a comment (#1924)
* fix: cursor jumps to end of text when editing a comment

When editing a comment mid-text, the cursor would jump to the end after
every keystroke, making it impossible to insert text at any position
other than the end.

Root cause: on each keystroke, the comment editor's onUpdate callback
updated parent state (setContent), which changed the defaultContent prop
passed back to CommentEditor. A useEffect watching defaultContent then
called commentEditor.commands.setContent(), which reset the entire
editor content and moved the cursor to the end.

Fix:
- Store in-progress edits in a ref instead of state to avoid triggering
  React re-renders and the prop->effect->setContent cascade
- Read from the ref when saving the comment
- Sync the ref back into state after a successful save so the read-only
  view updates immediately
- Guard the setContent useEffect to only run for read-only editors, so
  websocket-driven updates from other browsers still work

Fixes #1791

Functionally tested on Firefox and Chrome: mid-text editing, saving,
cross-browser live updates via websocket.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix stale content on edit cancel

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Philipinho <16838612+Philipinho@users.noreply.github.com>
2026-02-09 15:16:40 -08:00
2026-01-16 13:21:42 +00:00
2025-03-06 13:38:37 +00:00
2025-03-06 13:38:37 +00:00
2024-01-09 18:58:26 +01:00
2025-01-04 13:22:31 +00:00
2026-02-06 10:28:52 -08:00
2026-01-16 13:21:42 +00:00
2023-11-15 23:11:15 +00:00
2024-01-09 18:58:26 +01:00
2026-02-06 11:32:00 -08:00
2025-04-21 21:50:21 +01:00

Docmost

Open-source collaborative wiki and documentation software.
Website | Documentation | Twitter / X


Getting started

To get started with Docmost, please refer to our documentation or try our cloud version .

Features

  • Real-time collaboration
  • Diagrams (Draw.io, Excalidraw and Mermaid)
  • Spaces
  • Permissions management
  • Groups
  • Comments
  • Page history
  • Search
  • File attachments
  • Embeds (Airtable, Loom, Miro and more)
  • Translations (10+ languages)

Screenshots

home editor

License

Docmost core is licensed under the open-source AGPL 3.0 license.
Enterprise features are available under an enterprise license (Enterprise Edition).

All files in the following directories are licensed under the Docmost Enterprise license defined in packages/ee/License.

  • apps/server/src/ee
  • apps/client/src/ee
  • packages/ee

Contributing

See the development documentation

Thanks

Special thanks to;

Crowdin

Crowdin for providing access to their localization platform.

Algolia-mark-square-white

Algolia for providing full-text search to the docs.

Languages
TypeScript 96%
CSS 3.8%