Fix batch editing regressions#2411
Merged
tf merged 5 commits intocodevise:masterfrom Apr 29, 2026
Merged
Conversation
After an external value replacement removes content from a text block, slate-react's throttled `selectionchange` listener can read the browser's DOM cursor — clamped by the browser to the start of the now-shrunken contenteditable — and re-sync it into `editor.selection`. `Selection`'s auto-select branch then treats that synthetic selection as a user click and re-selects the content element, overriding whatever the calling op had selected (e.g. a freshly inserted image). Clear the DOM cursor alongside the Slate selection in `resetSelectionIfOutsideNextValue`, but only when the cursor sits inside this editor's contenteditable, so other DOM selections on the page are left alone. REDMINE-21261
Adjust the order in `Batch.save`'s `success` callback to avoid
visible intermediate states. Each apply phase travels from the
parent editor to the iframe as a separate postMessage and is rendered
in its own React commit (no batching across postMessages), so each
phase's intermediate state can paint on screen.
New order: permaIds, threads, configuration, positions, additions,
deletions. Splitting permaId stamping out of `applyAdditions` lets
`applyThreadUpdates` resolve `target.get('permaId')` against still-
dangling new elements — the iframe sees no React paint until the
collection mutation in `applyAdditions` later. Threads update before
configuration so the originator's value-flip render already observes
migrated ranges. Positions are stamped before additions so Backbone's
collection comparator drops new elements into their sorted slot on
add. Configuration before deletions lets a delete-merge survivor grow
to its merged content before its sibling disappears, avoiding a
brief collapse.
REDMINE-21261
The in-render reset (kypwynyx) saved a render commit but folded the value flip into the same React paint as the upstream Backbone event that delivered the new value. With each `Batch.success` apply phase arriving as a separate postMessage and turning into a separate sync render in the iframe (no React batching across postMessages), the deferred form sequences the value flip after the surrounding apply events have committed — noticeably smoother for delete-merge in Firefox, where the deletion paint lands before the survivor expands. Keep mkyzypsy's post-commit \`previousValue.current = value\` effect: without it, a local edit following a debounced save would misread the synced upstream value as an external change. REDMINE-21261
Same root cause as the auto-select guard in `EditableText/Selection`: slate-react's throttled `selectionchange` listener can sync a clamped DOM cursor back into `editor.selection` after the user has clicked away. `BadgeColumn` would then read a non-null `editor.selection`, `highlightOverlapsSelection` would return true if the synthetic cursor happened to land in a highlighted range, and the badge would flip from `dot` to overlap mode without an actual user selection. Gate `editorSelection` on `ReactEditor.isFocused(editor)` so badges fall back to dot mode whenever the editor isn't focused. REDMINE-21261
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.
REDMINE-21261