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
Mantine >= 5.10.5 menu rendered with react-dom hydrate
causes memory leak if transition props are provided
#3643
Comments
please provide a codesandbox (template– https://codesandbox.io/s/mantine-template-9ze89?file=/src/App.tsx:0-6) with minimal reproducible example https://stackoverflow.com/help/minimal-reproducible-example. It is not possible to identify the issue without reproduction. |
Sorry for the delay! I was unable to reproduce it in a few codesandboxes but finally managed to reproduce with the Mantine Remix template. https://codesandbox.io/p/sandbox/morning-star-de8v1w A few notes from trying to debug this that might be helpful to you:
|
hydrate
API
hydrate
API
If you remove all the transition props, then it appears to work again. So for example, in my codesandbox above, remove all the props to |
hydrate
API freeze the browser if transition props are provided
hydrate
API freeze the browser if transition props are providedhydrate
API freeze the browser if transition props are provided
hydrate
API freeze the browser if transition props are providedhydrate
API causes memory leak if transition props are provided
hydrate
API causes memory leak if transition props are providedhydrate
causes memory leak if transition props are provided
hydrate
causes memory leak if transition props are providedhydrate
causes memory leak if transition props are provided
The same is happening to us, had to revert to 5.10.4 to workaround it. |
I might have a hunch but not a solution. HunchThe following line might be part of the problem and therefore part of the solution: BackgroundHere's a bit background after digging through it:
Fixing the exampleBy changing the placement in your example to You can also add some space above the button (e. g. with A possible workaroundThis also may be the workaround until there's a solution:
SolutionMaybe finding a better The |
If I remember correctly where this is coming from, the key was needed for the correct computed position to be applied. Since there has been some more work done on the positioning since then, the key might actually not be necessary at all, we could try removing it and see. I'll dive back into my previous MR to remember exactly which case the key was fixing in the first place. |
Thanks for helping out so quickly. It's appreciated! |
Preliminary investigation: the key is still needed for what it's been introduced for in the first place. Removing it, dynamically updating the position via props will fail on scroll/resize, the initial position is restored. I'm going to dive deeper into this, coming up with a better key. The fact of the matter is, this needs to react to props changes, not internal computed position changes. I'll investigate further, using the reproduction as playground. Naive solution: propagate the props-set position and use this as key. Better solution: deep dive to understand why the initial bug is happening, and how to properly solve it without key. |
Hi @aniravi24, after investigating I found a workaround removing the need of I can provide a patch applicable through patch-package on latest v5 too. |
Thank you all for diving into this. @jvdsande I think I made all the code changes already to update to v6, so unless I find anything else that doesn't work (will put in a separate bug report if I do), implementing it in v6 works for me at least. Thank you! |
Great, thanks for taking care of this @jvdsande 👍 |
Hey @jvdsande can you please share the |
What package has an issue
@mantine/core
Describe the bug
Mantine 5.10.4 and below has no issues, but trying to open a
Menu.Dropdown
in Mantine 5.10.5 causes the browser to freeze and the menu doesn't open. Browser memory usage spikes from a couple hundred MB to multiple GB for that tab in Chrome if I keep the commit below.What version of @mantine/hooks page do you have in package.json?
5.10.5
If possible, please include a link to a codesandbox with the reproduced problem
https://codesandbox.io/p/sandbox/morning-star-de8v1w
Do you know how to fix the issue
No
Are you willing to participate in fixing this issue and create a pull request with the fix
None
Possible fix
Reverting this commit fixes this issue.
#3576
The text was updated successfully, but these errors were encountered: