question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't toggle by using '@click' with onClickOutside

See original GitHub issue

Describe 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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sibbngcommented, May 12, 2022

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.

1reaction
sibbngcommented, Mar 15, 2022

@sibbng Isn’t that what I did here?

Sorry, I didn’t look at your code carefully. You need to pass userMenuDropdownRef as Ref, not its value.

- onClickOutside(userMenuDropdownRef.value, (e) => {
+ onClickOutside(userMenuDropdownRef, (e) => {
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found