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]: Interacting with third-party components that use portals inside a Dialog closes the Dialog

See original GitHub issue

What package within Headless UI are you using?

@headlessui/vue

What version of that package are you using?

1.0.0

What browser are you using?

Firefox

Reproduction repository

https://codesandbox.io/s/pensive-fast-yxokp?file=/src/App.vue

Describe your issue

When any component inside a Dialog renders itself elsewhere in the DOM using a Portal/Teleport, clicking in it closes the entire Dialog. The example above uses vue-flatpickr-component to create a date picker inside a modal, but because it renders the actual flatpickr instance somewhere else in the DOM, clicking any date closes the entire modal.

The docs on this say:

When a Dialog is rendered, clicking the DialogOverlay will close the Dialog.

But that isn’t exactly the case—it’s not clicking the DialogOverlay specifically that closes the Dialog, but clicking anything that is not a child of the Dialog in the DOM.

I believe the relevant part of the code is here: https://github.com/tailwindlabs/headlessui/blob/main/packages/%40headlessui-vue/src/components/dialog/dialog.ts#L174-L184

What do you think about adding a way to disable that global mousedown handler, or adding an option to actually only close the Dialog based on clicks directly on the DialogOverlay component?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:20
  • Comments:28 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
RobinMalfaitcommented, Mar 24, 2022

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

This should be fixed #1268, and will be available in the next release.

You can already try it using:

  • npm install @headlessui/react@insiders or yarn add @headlessui/react@insiders.
  • npm install @headlessui/vue@insiders or yarn add @headlessui/vue@insiders.

I’ve updated your CodeSandbox with the latest insiders build: https://codesandbox.io/s/sweet-tree-egth6u

3reactions
dcastilcommented, Dec 14, 2021

I opened a PR to fix the issue for the React-specific version in https://github.com/tailwindlabs/headlessui/pull/989. Not sure though whether this fix is also applicable in Vue since it relies on the event delegation system of React which also propagates events through portals.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Overview - Dialogs - Kendo UI for Angular
The Dialogs Package is part of Kendo UI for Angular, a professional grade UI library with 100+ components for building modern and feature-rich...
Read more >
Using DialogFragment | CodePath Android Cliffnotes
Overview. DialogFragment is a specialized Fragment used when you want to display an overlay modal window within an activity that floats on top...
Read more >
Solved: dialog window in client script - alternative for s...
Hi,. we have a client script which opens a new window for some terms and conditions acknowledgement which is not working for the...
Read more >
Lightning Aura Components Developer Guide
Create Aura Components in the Developer Console . ... Using a Third-Party Framework . ... The notice is rendered as a modal dialog...
Read more >
Buttons for workflow transitions on Customer Portal - Jira
The third screen shows what happens after the user selected “close request”, a dialog appears which allow the customer to leave an optional...
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