Skip to content
This repository was archived by the owner on May 11, 2026. It is now read-only.

fix: prevent cursor jumping to end when editing blog content#35

Open
PxPerfectMike wants to merge 1 commit into
Safvan-tsy:mainfrom
PxPerfectMike:fix/editor-cursor-jump
Open

fix: prevent cursor jumping to end when editing blog content#35
PxPerfectMike wants to merge 1 commit into
Safvan-tsy:mainfrom
PxPerfectMike:fix/editor-cursor-jump

Conversation

@PxPerfectMike
Copy link
Copy Markdown

Summary

Fixes #31 — The text cursor was jumping to the end of the editor content after typing a single character.

Root Cause

The useEffect in Tiptap.tsx had content in its dependency array:

useEffect(() => {
  editor.commands.setContent(value);
}, [editor, content]); // ← content triggers on every keystroke

This created a feedback loop:

  1. User types a character → onUpdate fires → parent state updates content
  2. content change triggers useEffect → calls setContent() with full content
  3. setContent() replaces all editor content and resets cursor to end

Fix

Remove content from the dependency array so setContent() only runs when the editor initializes:

useEffect(() => {
  editor.commands.setContent(content);
}, [editor]); // ← only runs on editor init

The editor's internal state is managed by Tiptap via the onUpdate callback. The useEffect only needs to set the initial content once when the editor mounts.

Files Changed

  • app/components/editor/Tiptap.tsx — one-line fix in useEffect dependency array

Remove `content` from useEffect dependency array to break the
feedback loop where every keystroke would trigger setContent(),
resetting the cursor position to the end.

The editor's internal state is managed by Tiptap via onUpdate.
The useEffect only needs to run once when the editor initializes
to set the initial content.

Fixes Safvan-tsy#31
@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 23, 2026

@PxPerfectMike is attempting to deploy a commit to the safvantsy's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to properly edit from the editor

1 participant