Scroll to focus point of expanded selections#5968
Scroll to focus point of expanded selections#5968dylans merged 2 commits intoianstormtaylor:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 0ecace7 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 |
|
Hi @dylans, it looks like the issue you're seeing on the Playwright integration test was a random flake, probably caused by the page taking slightly longer than usual to load. The same test succeeded on its second attempt. I'm pretty sure it's unrelated to this PR. https://github.com/ianstormtaylor/slate/actions/runs/19149811365/job/54736850063?pr=5968#step:4:1328 |
|
Yeah the chunking test's flakiness seems unrelated to my changes. When I run the test locally, it's failing at the same rate on both my feature branch and the |
Currently,
defaultScrollSelectionIntoViewonly scrolls collapsed selections into view, citing the following concern:slate/packages/slate-react/src/components/editable.tsx
Lines 1954 to 1955 in c6137cd
This causes a bug when undoing the deletion of a range of text. To reproduce:
Bug_screen_capture.mp4
This PR updates
defaultScrollSelectionIntoViewto allow scrolling when the selection is expanded, but it specifically scrolls to the focus point of the selection (rather than trying to scroll to the entire selected range). This fixes the undo-after-delete bug:Fix_screen_capture.mp4
And scrolling to the focus point appears to avoid the issues with "the selection of multiple blocks and dragging behavior" that the original comment mentions. I've experienced those issues in development when allowing scrolling to expanded selections if I'm still trying to scroll to the entire
domRange. But we've made thisdomFocusPointchange in our project's customscrollSelectionIntoView, and I can't find any undesired behaviors when creating large selections, using either the mouse or the keyboard.Checks
yarn test.yarn lint. (Fix errors withyarn fix.)yarn start.)yarn changeset add.)