Replies: 1 comment
-
I ended up doing: function RouteChangeAutoClosePopover(props: { children: ReactNode }) {
const { children } = props;
const [isOpen, setIsOpen] = useState(false);
const pathname = usePathname();
useEffect(() => {
setIsOpen(false);
}, [pathname]);
return (
<Popover open={isOpen} onOpenChange={setIsOpen}>
{children}
</Popover>
);
} But I would like to have a more generic approach. Maybe having an additional prop to RouteChangeAutoClosePopover named |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi
I have an app with a Popover component for a menu.
Inside the popover, the user can navigate to a different section if the app with client-side navigation via the
Link
component fromnext/link
. When I navigate to the URL, the popover keeps being open. I wonder what is the best practice of closing it when the user clicks on the link. I can wrap it withPopover.Close
/ programmatically withonClick
- but I wonder if there is a better way to handle this case. What do you think?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions