fix(OUT-4019): guard against stale table selection on drop - #234
Closed
priosshrsth wants to merge 1 commit into
Closed
fix(OUT-4019): guard against stale table selection on drop#234priosshrsth wants to merge 1 commit into
priosshrsth wants to merge 1 commit into
Conversation
prosemirror-tables' createSelectionBetween returns view.state.selection while a cell selection is active. Callers that resolve against an already-modified doc (drop handler, DOM-change reader) then pass that stale selection to tr.setSelection and hit a RangeError. Adds a higher-priority plugin that returns a selection valid for the doc actually being resolved against, and defers to the table plugin otherwise. Fixes CLIENT-HOME-V3-1M Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThe PR adds a high-priority ProseMirror plugin that prevents the table editing plugin from returning a selection tied to the pre-change document.
Confidence Score: 5/5The PR appears safe to merge; no concrete blocking or independently actionable non-blocking issues were identified. The guard precedes the table editing plugin, defers under normal current-document selection handling, and intercepts the documented stale-document path with a selection resolved against the callback document. Important Files Changed
Reviews (1): Last reviewed commit: "fix(OUT-4019): guard against stale table..." | Re-trigger Greptile |
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.
Dropping content while a table cell selection is active threw
RangeError: Selection passed to setSelection must point at the current document. OUT-4019 · SentryRoot cause is upstream:
prosemirror-tables'tableEditingplugin returns the currentview.state.selectionfrom itscreateSelectionBetweenprop whenever a cell selection is active. ProseMirror's drop handler calls that prop after it has already modified the doc, then passes the stale selection totr.setSelection— which throws. The DOM-change reader (readDOMChange) has the same shape, so this isn't drop-only, just rarer.What to look at
Table.ext/table-stale-selection-guard.ts— the guard returnsnullwhen$anchor.doc === view.state.doc, which makessomePropfall through to the table plugin and leaves normal cell-selection dragging untouched. It only returns a selection when the docs differ. Confirm that read ofsomeProp's first-non-null semantics.priority: 1000— required so this plugin is consulted beforetableEditing. Worth a second pair of eyes given Tiptap reverses the extension list before sorting by priority.Verified / not verified
Verified:
pnpm typecheckandpnpm lintpass.Not verified: no automated test. Vitest here runs
environment: 'node'with no jsdom, and the two things that could actually break — plugin ordering and the ProseMirror prop contract — need a real editor to exercise. Manual repro is the check: select cells in a table, drag content, drop into the selected cell.Regression surface is table editing generally — cell selection via mouse drag, drag-and-drop in and out of tables, and IME/composition input inside cells.