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

Can't stop propagation with useClickAway #249

Open
kttmv opened this issue Oct 19, 2023 · 3 comments
Open

Can't stop propagation with useClickAway #249

kttmv opened this issue Oct 19, 2023 · 3 comments

Comments

@kttmv
Copy link

kttmv commented Oct 19, 2023

I have a SideMenu component, that should be closed when clicking outside of it, and a NavBar component with a button that toggles the SideMenu. When the SideMenu is open and I click the toggle button, two actions are dispatched: sideMenuClosed and sideMenuToggled. Basically, the SideMenu first closes and then immediately re-opens.

I've tried doing this, but it didn't help:

const ref = useClickAway((e) => {
    e.stopPropagation()
    e.stopImmediatePropagation()
    dispatch(sideMenuClosed())
})
@tylermcginnis
Copy link
Collaborator

Any chance you can make a simple replication of it for me with Codesandbox?

@kttmv
Copy link
Author

kttmv commented Oct 24, 2023

Here's the replication

@KevinArce98
Copy link

is there any solution for 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

No branches or pull requests

3 participants