Open mehdikhan55 opened 1 month ago
Hi @mehdikhan55, can you assign this issue to me. I love to fix this issue.
I am countering same issue any solution
Dropdown Menu Pointer Events Not Resetting
The dropdown menu component is not resetting the pointer-events style on the
after interacting with the dropdown. This makes the body unresponsive.Steps to Reproduce Open the dropdown menu. Select an item that triggers a dialog. Cancel the dialog.
Expected Behavior The
should allow interactions after the dialog is canceled.Actual Behavior The
retains the style pointer-events: none;, preventing any interactions.Proof:
Before opening the dropdown:
After canceling the dialog: Temporary Solution Manually setting pointer-events to auto resolves the issue. Suggested Fix Implement a mechanism to reset pointer-events to auto on the when the dropdown is closed or when the dialog is canceled.As @abdelbassetbabeker suggested, i simply do the following for now:
const handleOpenChange = (open: boolean) => {
if (!open) {
//remove the style="pointer-events: none;" from the body
document.body.style.pointerEvents = "auto"
}
}
Use this on the DropdownMenu root's onOpenChange handler
This seems to be a bug in radix-ui.
As @abdelbassetbabeker suggested, i simply do the following for now:
const handleOpenChange = (open: boolean) => { if (!open) { //remove the style="pointer-events: none;" from the body document.body.style.pointerEvents = "auto" } }
Use this on the DropdownMenu root's onOpenChange handler
This seems to be a bug in radix-ui.
I'm questioning the sanity of my own solution, I just give time for the current dialog to close (finish the animation) before closing the parent (timeout with 300ms before calling my parent's onSuccess?.()
)...
const [open, setOpen] = useState(false);
const justificationRef = useRef<HTMLDivElement>(null);
const code = row.original.type;
const copyToClipboard = async () => {
if (justificationRef.current === null) {
return;
}
try {
await copyElementContent(justificationRef.current);
setOpen(false);
if (!isDropdownItem) {
row.toggleSelected(true);
}
toast.success('Justification copied to clipboard.');
setTimeout(() => {
// Trigger parent success after the dialog close animation is done
// to prevent page level unresponsiveness
onSuccess?.();
}, 300);
} catch (err) {
toast.error('Failed to copy text.', {
description: (err as Error)?.message,
});
}
};
return (
<Dialog open={open} onOpenChange={setOpen}>
Describe the bug
Hi. I am trying to use Dropdown component inside of data table. I am using Next.js. Opening this dropdown causes whole page to freeze.
The whole code is given below:
Affected component/components
Drop-down and Data-table