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.

[Bug]: Dialog blocks click event listener

See original GitHub issue

What package within Headless UI are you using?

@headlessui/vue

What version of that package are you using?

1.4.1

What browser are you using?

Chrome

Reproduction repository

https://codesandbox.io/s/bug-headless-ui-dialog-click-outside-8n3jh

Describe your issue

Click event listener is not emitted on dialogs.

The problem with this is that I’m trying to make a dropdown that closes when clicking outside. To do that I want to add a global event listener for the click event, but it’s not being triggered.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:7

github_iconTop GitHub Comments

11reactions
RobinMalfaitcommented, Mar 2, 2022

Hey! Thank you for your bug report! Much appreciated! 🙏

This is done on purpose. You should think of a Dialog as a separate page where you shouldn’t interact with things behind it. Putting an event listener on the document is technically interacting with things behind the Dialog.

If you want to implement a dropdown that closes when you click outside, then you should be able to use our Menu component that has this functionality outside of the box.

Here is an example: https://codesandbox.io/s/bug-headless-ui-dialog-click-outside-forked-21t72y?file=/src/App.vue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Violation 'click' handler took 239ms - When dialog rendering ...
I am using <Dialog></Dialog> Material UI to render the React Hook Form (form Popup). When the data is small. It is working well....
Read more >
The Dangers of Stopping Event Propagation - CSS-Tricks
This bug happens because the Bootstrap code responsible for closing the dropdown menu is listening for click events on the document.
Read more >
Inconsistent popup-blocker behavior with document ...
Bug 1379466 - Stop dispatching click events for non-primary mouse clicks on the web. 4 years ago. Ian Moody [:Kwan] (UTC+1).
Read more >
How to Make Dialogs (The Java™ Tutorials > Creating a GUI ...
A Dialog can be modal. When a modal Dialog is visible, it blocks user input to all other windows in the program. JOptionPane...
Read more >
React: Event Bubbling and Capturing - Robin Wieruch
In conclusion, whenever there is a element with a handler nested in another element with a handler, where both are listening to the...
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