Repository navigation
fix(slate-history): preserve unsaved edits inside inserted subtrees - #6370
Open
peterolkhov wants to merge 1 commit into
Open
peterolkhov wants to merge 1 commit into
peterolkhov wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 0023576 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
dylans
requested changes
Nov 20, 2026
| side: Side | ||
| ): Operation[] | null => { | ||
| if ( | ||
| op.type === 'remove_node' && |
Collaborator
There was a problem hiding this comment.
transformOperationsalso callstransformwith the unsaved op first (line 242), so this check runs both ways- an unsaved removal of a block now drops any saved batch that touched that block, including its edits in other blocks
- tried it: set both blocks to
h1in one batch, remove block 1 without saving, undo - main turns block 0 back to
p, on this branch there is nothing left to undo and block 0 staysh1 - run the check only on the history op, e.g.
if (removesUnsavedEdit(ops[0], by[0])) return nullin the single op case oftransformOperations, and add a test for this case
| removed, or that can no longer be applied, such as a split whose halves are no | ||
| longer next to each other, is dropped. | ||
|
|
||
| A batch that would remove a whole node is also dropped if an unsaved change |
Collaborator
There was a problem hiding this comment.
- this drops the user's latest step in a common collaboration case
- type "b", insert paragraph "x", a collaborator types "R" in "x" without saving
- first undo on main removes "x", on this branch it skips "x" and removes "b"
- same when the unsaved change is only a
setNodeson "x", with no text at risk - for edits inside the node, could the stored node in the
remove_nodeget the unsaved change applied instead of dropping the batch?
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Save an inserted paragraph, append text inside it with
HistoryEditor.withoutSaving, then undo and redo: the paragraph comes back without the unsaved text. Unsaved child blocks inside a saved container can disappear the same way. Rebasing keeps a whole-node removal whose stored contents predate those edits.Treat that removal as incompatible when it would swallow an unsaved update at or inside the subtree. This uses the existing conservative history fallback: the entire conflicting batch is dropped, so its container, original saved content and any unrelated operations in that batch remain applied. The next surviving batch stays undoable. This preserves unsaved data at the cost of that batch's undoability; it does not implement selective undo or general collaboration semantics. The existing dependent-redo truncation policy is unchanged.
The four-file change adds the guard, 22 regression cases, a short
withoutSavingbehavior note and a patch changeset. Fourteen regressions fail on the original source; all 22 pass with the fix. Independent review passes another 15 adversarial cases, including collateral operations in a discarded batch and neighboring history.Validation: canonical build and lint pass; Mocha has 2,912 passing and 10 pending, Jest has 385 passing across 51 suites, and all five docs checks pass. The test commands ran separately, with Jest serialized. Browser/IME checks were not run for this history-only change. The coarse batch policy is the main compatibility choice to review.
If the TypeDoc migration in #6045 lands first, the new behavior note will need to move into the
withoutSavingJSDoc.