-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: default scroll selection #4652
Conversation
🦋 Changeset detectedLatest commit: 7efec9b 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 |
Let me know if there is any change required. I know we can pass custom function to override this. But it's better to provide the default behaviour correctly within slate itself. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hit approve prematurely... in general I think you're on the right track, but there's likely a better way to do this. Just landed after an overnight flight so I'll respond with feedback once my brain is working fully. :)
@@ -1326,6 +1326,9 @@ const defaultScrollSelectionIntoView = ( | |||
editor: ReactEditor, | |||
domRange: DOMRange | |||
) => { | |||
if (editor.selection?.anchor?.path[0] !== editor.selection?.focus?.path[0]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if the check is for an expanded range, if so Range.isExpanded
should be used. If not, a variable should be extracted so that the conditional is a bit more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot that we have helper methods.
@dylans any update on this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall I think this change is fine (see my grammar suggestion), but I'm not sure if it fully fixes the issue as there might be other scenarios leading to this issue. But let's go ahead and land this and see if there are remaining scenarios that break scrolling.
scrollMode: 'if-needed', | ||
}) | ||
delete leafEl.getBoundingClientRect | ||
// This was affecting the selecting multi blocks and dragging behaviour so, enabled only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// This was affecting the selecting multi blocks and dragging behaviour so, enabled only | |
// This was affecting the selection of multiple blocks and dragging behavior, so enabled only |
P.S. This one needs a changeset as well, thanks! |
I added changeset, thanks again. |
Description
Disabled the auto scroll behaviour when it's on selection
Issue
Fixes: (link to issue)
#4647
Checks
yarn test
.yarn lint
. (Fix errors withyarn fix
.)yarn start
.)yarn changeset add
.)