Skip to content

Comments

fix: forward on insert.text breaks undo batching#2243

Draft
christianhg wants to merge 1 commit intomainfrom
fix/forward-undo-batching
Draft

fix: forward on insert.text breaks undo batching#2243
christianhg wants to merge 1 commit intomainfrom
fix/forward-undo-batching

Conversation

@christianhg
Copy link
Member

Problem

When a behavior uses forward(event) on insert.text with a second action set, each typed character becomes its own undo step instead of merging with adjacent characters.

This breaks the expected undo behavior for any behavior that observes text insertion without modifying it (e.g., a behavior that forwards the text and then checks the block content to update styles).

Root cause

performEvent sets a unique undoStepId for every insert.text event because it's synthetic (not in nativeBehaviorEventTypes). Without custom behaviors, the default handler clears undoStepId before running the operation, so consecutive characters merge. But when a behavior forwards the event, defaultBehaviorOverwritten = true and the clearing never happens. Each character gets a unique undoStepId, preventing history merge.

Status

Failing tests added. Fix pending.

@vercel
Copy link

vercel bot commented Feb 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
portable-text-editor-documentation Ready Ready Preview, Comment Feb 23, 2026 5:55pm
portable-text-example-basic Ready Ready Preview, Comment Feb 23, 2026 5:55pm
portable-text-playground Ready Ready Preview, Comment Feb 23, 2026 5:55pm

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Feb 23, 2026

⚠️ No Changeset found

Latest commit: 283a933

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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