-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Bug]: Interacting with third-party components that use portals inside a Dialog closes the Dialog #432
Comments
I have the same issue as described, clicking on the calendar provided by |
I Also have the same issue with showing a loading indicator above the Modal, any accidental clicks on the loading indicator will then close the modal. |
I can confirm the issue. I use dialog with scrollable content that contains a selectbox. The selectbox options list is rendered at body level in a teleport and positioned with popper. Clicking on the options list will close the dialog. |
is there a workaround for this? seeing the same issue with |
I was able to get it working on my project for now by also setting |
I have the same issue as described, clicking on the calendar provided by devextreme closes the Dialog. |
I am using CKeditor BalloonEditor the Modal also close after clicking editor toolbar. |
What is the fix/solution or status of this? I would really like to use headless UI for dialogs and other things but cannot if it breaks my existing usage of third party libraries such as flatpickr. |
i have the same issue. when i use some element over the dialog and click the element, dialog will be close |
What about changing the
to a click handler on the overlay instead? |
Any news about the fix? |
Hey there! 👋🏻 Small bump of the issue. |
I opened a PR to fix the issue for the React-specific version in #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. |
I'm using react. And this comment solve my issue.
Thanks @RobinMalfait |
With React just add this it worked for me: |
With Vue, it does not work... |
This could work. The quick solution would be to remove the You still need to handle other way of closing the dialog, like pressing the Escape key. I don't know if there are other things I am missing, here is an example. <Dialog as="div" [...] @keydown.esc="$emit('close')" static>
<DialogOverlay [...] @click="$emit('close')" />
</Dialog> |
After testing the solution I have proposed, there are still issues with |
any workaround in vue? |
same bug. What's taking so long? |
Hey! Thank you for your bug report! This should be fixed #1268, and will be available in the next release. You can already try it using:
I've updated your CodeSandbox with the latest insiders build: https://codesandbox.io/s/sweet-tree-egth6u |
Thanks! That demo works for me, I have a few questions though that I'll leave as comments on the PR. |
steve@5950x:~/Documents/GitHub/mavrik/nftcompany-frontend$ npm install @headlessui/react@insiders npm ERR! A complete log of this run can be found in: NEVERMIND: npx pnpm install @headlessui/react@insiders This is why I'm a Flutter dev. JS is non stop weird bugs. |
It worked but there is a bug with @vuepic/vue-datepicker https://codesandbox.io/s/exciting-fog-cefyoh?file=/src/App.vue |
@eskiesirius do you mind telling me what the bug is? 😅 |
sorry but it opens automatically |
@eskiesirius that's because the library is implemented to open when it receives focus. And the Dialog component focuses the first focusable item. If you don't want this behaviour: https://headlessui.dev/vue/dialog#managing-focus-within-your-dialog |
okay.. thank you so much!!! can you refer this to my issue i posted here? |
I still have an issue related to the portal and the I use Here is an exemple https://codesandbox.io/s/billowing-thunder-0s724d |
I have the opposite problem. |
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:
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 theDialogOverlay
component?The text was updated successfully, but these errors were encountered: