Skip to content

[ScrollArea] scroll-behavior: smooth compatibility #2175

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

Merged
merged 1 commit into from
May 30, 2023

Conversation

benoitgrelard
Copy link
Contributor

Fixes #2064

@@ -715,6 +715,7 @@ const ScrollAreaScrollbarImpl = React.forwardRef<
// so we remove text selection manually when scrolling
prevWebkitUserSelectRef.current = document.body.style.webkitUserSelect;
document.body.style.webkitUserSelect = 'none';
if (context.viewport) context.viewport.style.scrollBehavior = 'auto';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also need to do something to address the wheel interaction mentioned in the issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I tested using my mouse wheel, and using my trackpad and there was no issue with those.
Similarly, I tested with touch drag on my iPhone and it was fine too.

This makes sense to me as it makes sense that scroll-behavior: smooth takes that into account already.

@@ -725,6 +726,7 @@ const ScrollAreaScrollbarImpl = React.forwardRef<
element.releasePointerCapture(event.pointerId);
}
document.body.style.webkitUserSelect = prevWebkitUserSelectRef.current;
if (context.viewport) context.viewport.style.scrollBehavior = '';
Copy link
Contributor

@andy-hook andy-hook May 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any risk that this event wouldn't fire? I'm curious as the capture release code is above this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, what are you thinking?

Copy link
Contributor

@andy-hook andy-hook May 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this looks good. Raising the question just in case 😄

@benoitgrelard benoitgrelard merged commit 94d229d into main May 30, 2023
@benoitgrelard benoitgrelard deleted the scroll-area-smooth-behaviour branch May 30, 2023 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ScrollArea event-based scrolling does not work with scroll-behavior: smooth
2 participants