ui
ui copied to clipboard
[BUG] Context Menu position not updating
The postion of the menu dose not update if the menu is already open and the user right clicks in another location in the same target.
This works properly in the "Radix UI" implimentation where the location of the menu changes properly.
In shadcn, the menu keeps repoening in the inital location no matter where in the target container the user clicks.
@shadcn I'd like to check this out if this is a valid bug.
@Taimoor-Tariq @shadcn, The problem arises when you unclick before the previous context menu properly closed. However, if you wait for the previous context menu to completely close before clicking again, the functionality works without any problems. So, data-[state=closed]:animate-out class is causing the issue.
can confirm that removing the data-[state=closed]:animate-out class fixes the issue
Yup, I've tested it. Removing the class fixes the bug but it will also remove the context menu's closing animation.
It seems this is the issue from Radix UI itself. @Taimoor-Tariq @shadcn, Do you guys think we can close this or you have something else in your mind to fix this?
I've found this to be working in the latest documentation of radix UI: https://www.radix-ui.com/primitives/docs/components/context-menu Updating Radix UI to the latest version however doesn't fix the issue in ShadCN.
Edit: I've tried to debug this issue and found out that this issue is caused by one or multiple of the following classes (line 63), removing all of them resolves the issue:
animate-in fade-in-80 data-[state=open]:animate-in
data-[state=closed]:animate-out data-[state=closed]:fade-out-0
data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95
data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2
data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2
Edit 2: Further narrowing down the cause, I've found that removing the class data-[state=closed]:animate-out does fix the problem described above, at the cost of not having a closing animation.