Skip to content
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

Scrollbar rendering issue on the first scroll in ScrollArea #7257

Closed
2 tasks done
tamago324 opened this issue Dec 13, 2024 · 1 comment · Fixed by #7260
Closed
2 tasks done

Scrollbar rendering issue on the first scroll in ScrollArea #7257

tamago324 opened this issue Dec 13, 2024 · 1 comment · Fixed by #7260

Comments

@tamago324
Copy link
Contributor

tamago324 commented Dec 13, 2024

Dependencies check up

  • I have verified that I use latest version of all @mantine/* packages

What version of @mantine/* packages do you have in package.json?

7.15.1

What package has an issue?

@mantine/core

What framework do you use?

Other, I will specify in the bug description

In which browsers you can reproduce the issue?

Chrome

Describe the bug

The scrollbar does not change position at the first scrolling timing.
This was also confirmed on the Storybook and Mantine documentation, so I will put up a video

7.15.1

mantine_7.15.1_scrollarea.mp4

7.14.3

mantine_7.14.3_scrollarea.mp4

If possible, include a link to a codesandbox with a minimal reproduction

No response

Possible fix

Using git bisect, I found the commit that caused this and confirmed that it behaves as it did in 7.14.3 by modifying it as follows. (ecd05d8)
However, I am not quite sure what it means, and would like to ask someone in the know to fix it.
Any feedback would be appreciated.

diff --git a/packages/@mantine/core/src/components/ScrollArea/ScrollAreaThumb/ScrollAreaThumb.tsx b/packages/@mantine/core/src/components/ScrollArea/ScrollAreaThumb/ScrollAreaThumb.tsx
index 8f5410fb6..81295aba2 100644
--- a/packages/@mantine/core/src/components/ScrollArea/ScrollAreaThumb/ScrollAreaThumb.tsx
+++ b/packages/@mantine/core/src/components/ScrollArea/ScrollAreaThumb/ScrollAreaThumb.tsx
@@ -13,7 +13,7 @@ export const Thumb = forwardRef<HTMLDivElement, ThumbProps>((props, forwardedRef
   const scrollbarContext = useScrollbarContext();
   const { onThumbPositionChange } = scrollbarContext;
   const composedRef = useMergedRef(forwardedRef, (node) => scrollbarContext.onThumbChange(node));
-  const removeUnlinkedScrollListenerRef = useRef<(() => void) | undefined>(noop);
+  const removeUnlinkedScrollListenerRef = useRef<(() => void)>();
   const debounceScrollEnd = useDebouncedCallback(() => {
     if (removeUnlinkedScrollListenerRef.current) {
       removeUnlinkedScrollListenerRef.current();

Self-service

  • I would be willing to implement a fix for this issue
@tamago324
Copy link
Contributor Author

I read the code.

It seemed that if I set useRef(noop), the scrollbar would not be redrawn while scrolling because addUnlinkedScrollListener() would not be called on the first scroll.
Therefore, it seems that it must be undefined at first.

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 a pull request may close this issue.

1 participant