Skip to content

Commit e97b4ac

Browse files
committed
fix: use TextSelection.between for list item cursor placement
Fall back to the nearest valid selection when the resolved anchor/head no longer sit inside a textblock, instead of constructing a possibly invalid TextSelection directly.
1 parent 545f322 commit e97b4ac

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • packages/components/src/list-item-block

packages/components/src/list-item-block/view.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ export const listItemBlockView = $view(
5757
if (anchor > docSize || head > docSize) return
5858
const anchorPos = state.doc.resolve(anchor)
5959
const headPos = state.doc.resolve(head)
60-
const selection = new TextSelection(anchorPos, headPos)
60+
// Use `between` so we fall back to the nearest valid selection when
61+
// the resolved positions no longer sit inside a textblock.
62+
const selection = TextSelection.between(anchorPos, headPos)
6163
view.dispatch(state.tr.setSelection(selection))
6264
})
6365
}

0 commit comments

Comments
 (0)