Repository navigation
fix(muya): stop drag-selection from expanding to whole blocks - #4477
Merged
Merged
Conversation
TextSelection.handleMousemoveOrClick grew any cross-block text selection to cover the entire enclosing block: a focus landing in a code block, list item, or table cell snapped the anchor offset to 0 and the focus offset to text.length, selecting the whole code block / list item / table. Remove the four expansion branches so the selection ends exactly where the pointer lands. The same-block early return is unchanged, and this does not touch TableRectSelection (rectangular cell drag) or the Cmd+A selectAll escalation, which are separate paths. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Add a Chromium e2e regression test that drags between two list items (interior char offsets) and asserts the resulting anchor/focus offsets stay interior, rather than snapping to whole-item bounds. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.
What
Text drag-selection no longer auto-expands to whole structural blocks. Previously, when a selection's anchor or focus landed inside a code block, list item, or table cell,
TextSelection.handleMousemoveOrClickgrew the selection to cover the entire enclosing block — snapping the anchor offset to0and the focus offset totext.length. The result was that landing in a list item selected the whole item, landing in a code block selected the whole code block, and landing in a table cell selected the whole table.Expectation (and new behavior): the selection ends exactly where the pointer lands — interior offsets stay interior.
How
TextSelection.handleMousemoveOrClick(and the now-unuseddirectiondestructure +Parent/ListItem/TaskListItemimports).isSelectionInSameBlockearly return is unchanged.TextSelectiontext-drag path. It does not affect:TableRectSelection— rectangular cross-cell drag selection (collapses the native range before this code runs, so the same-block early return fires).selectAll()— the Cmd+A escalation lives in a separate facade method.Testing
editing/text-selection-no-expand.spec.ts): drags between two list items at interior char offsets and asserts the offsets stay interior (the old expansion forced 0 / text.length). Confirmed red before the fix, green after.pnpm -C packages/muya lint:typesclean, ESLint clean.check-circularclean.table-cell-selection(rectangle selection intact) andselection.spec.ts(Cmd+A across blocks).🤖 Generated with Claude Code