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

[Context Menu] fix: stop infinite re-renders when the menu is closed #3386

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Randulfe
Copy link

@Randulfe Randulfe commented Feb 17, 2025

Description

When the context menu is closed the anchor component bringing the menu is still open so if a component using the context menu trigger re-renders quite frequently it will cause an infinite re-render loop with the menu as it's still rendered even when the context menu is supposed to be closed.

The problem seem to come from <MenuPrimitive.Anchor> which uses a virtual ref to measure its bounding client rect. If the trigger is frequently re-rendered it triggers constant state updates in the positioning logic (even the the context menu is closed) and ultimately causes an infinite update loop that has probably to do with radix's menu (not so familiar with it but it must be reacting with this in an inifinite rendering way).

Warning

This fixed the issue on my end that has also been reported here #2717 (comment) and in my issue #3385 but due to my unfamiliarity with this project please make sure this does not have any unintentional side effects.

@Harukisatoh
Copy link

Someone please give attention to this issue, this is open since February 2024.

@jarvis394
Copy link

Bump, also facing this issue

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.

3 participants