How to detect page navigation and i.e. close mobile menu?
I have full-screen mobile menu with Links and I'd like to close it on-navigate. What's the proper way to handle it?
4 Replies
equal-aqua•7mo ago
can you provide more details?
variable-limeOP•7mo ago
So usually, mobile menu closes when you clicks the link. Of course, I could probably use onClick() to handle that, but I'm not sure wheter it's the best practice here. Instead, I'd like to detect that the navigating process started, and then use this info to hide/close the mobile menu automatically, so it won't annoy the users
I know there is something like: router.history.subscribe(), but this would require some global state I guess
I hope there is some better solution as it's pretty common case
equal-aqua•7mo ago
yeah why not onClick?
it's exactly what you want
variable-limeOP•7mo ago
Well, looks like I always overcomplicate things 😅 onClick is good enough. Thanks