Skip to content

fix(core): derive onValueChange and onSelectionChange from onChange (#2700) - #5062

Closed
Samarth1306w wants to merge 3 commits into
udecode:mainfrom
Samarth1306w:fix/derive-slate-callbacks-2700
Closed

fix(core): derive onValueChange and onSelectionChange from onChange (#2700)#5062
Samarth1306w wants to merge 3 commits into
udecode:mainfrom
Samarth1306w:fix/derive-slate-callbacks-2700

Conversation

@Samarth1306w

@Samarth1306w Samarth1306w commented Aug 3, 2026

Copy link
Copy Markdown
  • Auto release

Description

Derives onValueChange and onSelectionChange directly inside the Slate onChange handler within useSlateProps.ts.

Problem Solved

Previously, onChange, onValueChange, and onSelectionChange were handled as independent callbacks. When Slate fired onChange, component subscribers to value or selection changes could miss updates or receive re-renders out of order.

Solution

Track prevValueRef and prevSelectionRef. Inside onChange:

  1. Trigger onValueChange and updateVersionValue() when editor.children changes.
  2. Trigger onSelectionChange and updateVersionSelection() when editor.selection changes.

Fixes #2700
/claim #2700

@codesandbox

codesandbox Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@changeset-bot

changeset-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0ad3179

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@platejs/core Patch

Not sure what this means? Click here to learn what changesets are.

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

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. core patch Bugfix & documentation PR labels Aug 3, 2026
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Aug 3, 2026
@zbeyens zbeyens closed this Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core patch Bugfix & documentation PR size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slate - Derive onSelectionChange and onValueChange from onChange

3 participants