Can't toggle by using '@click' with onClickOutside
See original GitHub issueDescribe the bug
onClickOutside doesn’t let me toggle the menu item on click. It opens it, onClickOutside works fine but can’t close the menu by clicking the button again. There is a workaround but maybe this should be corrected?: https://github.com/vueuse/vueuse/issues/1245
Reproduction
https://stackblitz.com/edit/vitejs-vite-7v9ofd/?file=src%2Fmain.js
System Info
System:
OS: Windows 10 10.0.19044
CPU: (16) x64 Intel(R) Core(TM) i7-10875H CPU @ 2.30GHz
Memory: 19.21 GB / 31.77 GB
Binaries:
Node: 16.13.0 - C:\Program Files\nodejs\node.EXE
npm: 8.4.1 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.19041.1266.0), Chromium (99.0.1150.39)
Internet Explorer: 11.0.19041.1566
Used Package Manager
pnpm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a VueUse issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Detect click outside React component - Stack Overflow
Show activity on this post. I'm looking for a way to detect if a click event happened outside of a component, as described...
Read more >Creating An Outside Focus And Click Handler React Component
In this article, we'll look at how to create an outside focus and click handler with React. We will recreate an open source...
Read more >How to detect a click outside a React component
In this tutorial, learn a few ways how to implement click detection outside of both functional and class-based React components.
Read more >handleClickOutside not bound when using functional ... - GitHub
react-onclickoutside.es.js:184 Uncaught Error: WrappedComponent lacks a handleClickOutside(event) function for processing outside click ...
Read more >Detect click outside React component - Material UI - MUI
The Click-Away Listener component detects when a click event happens outside of its child element.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s documented in the Type Declarations section. https://vueuse.org/core/onClickOutside/#type-declarations
The
ignore
option might be what you are looking for or you need to craft your solution by combining multiple composition APIs. If you could post your questions on Discussions page with some code samples you might get an answer from other people too.Sorry, I didn’t look at your code carefully. You need to pass
userMenuDropdownRef
as Ref, not its value.