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

Poor performance of closed Popover component onScroll #6771

Closed
1 of 2 tasks
yergom opened this issue Sep 4, 2024 · 1 comment
Closed
1 of 2 tasks

Poor performance of closed Popover component onScroll #6771

yergom opened this issue Sep 4, 2024 · 1 comment
Labels
Fixed patch Completed issues that will be published with next patch (1.0.X)

Comments

@yergom
Copy link

yergom commented Sep 4, 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.12.1

What package has an issue?

@mantine/core

What framework do you use?

Vite

In which browsers you can reproduce the issue?

All

Describe the bug

All the components based on Popover (Combobox, Select, Tooltip) re-render too many times when their viewport position changes. As an example, try to profile the following code while scrolling on the ScrollArea:

<ScrollArea h={300}>
    {new Array(100).fill(0).map((_v, idx) => (
      <Select
        key={idx}
        data={["React", "Angular", "Vue", "Svelte"]}
      />
    ))}
</ScrollArea>

The performance problem is not present if, for example, we use keepMounted = false or the Popover is disabled. See attached codesandbox for a comparison

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

https://codesandbox.io/p/sandbox/mantine-react-template-forked-rtgqx7

Possible fix

After looking at the implementation, I think that the main culprit is

As long as both refs are there, the effect will run the autoUpdate function. This explains why, when using keepMounted:false, the performance is fixed (because the floating ref is null). The fix is to only call autoUpdate if the floating is open

Self-service

  • I would be willing to implement a fix for this issue
rtivital added a commit that referenced this issue Oct 3, 2024
…number of closed Popovers are rendered on the same page (#6771)
@rtivital rtivital added the Fixed patch Completed issues that will be published with next patch (1.0.X) label Oct 3, 2024
@rtivital
Copy link
Member

rtivital commented Oct 3, 2024

Fixed in 7.13.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed patch Completed issues that will be published with next patch (1.0.X)
Projects
None yet
Development

No branches or pull requests

2 participants