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.

Using Dialog and Menu together: prompting user for confirmation from context menu fails to trigger onClick

See original GitHub issue

What package within Headless UI are you using? @headlessui/react

What version of that package are you using? 1.4.3

What browser are you using? Google Chrome Version 98.0.4758.80 (Official Build) (x86_64)

Reproduction URL https://codesandbox.io/s/confirm-dialog-in-context-menu-rryfbw?file=/pages/index.js

Note: Expected behavior of the above is that it should trigger a browser alert when you click Delete -> Confirm. It may work the first time. Please try multiple times, as the error behavior is intermittent.

Describe your issue When nesting a Dialog in a Menu, it appears that certain onClick events only fire sometimes, or there is otherwise odd behavior in handling click events when nesting a Dialog in a Menu.

I have a simple use case of having a delete button within a context menu (Menu). The delete button is wrapped in a custom component I call Confirm, that opens a Dialog and prompts the user to confirm the action (e.g. “Are you sure you want to delete that?”). The onClick handler of the “Confirm” appears to fire intermittently. I haven’t had much luck discerning whether or not it is firing but not being handled, or not firing at all.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:17

github_iconTop GitHub Comments

1reaction
RobinMalfaitcommented, Feb 18, 2022

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

Can you update the reproduction url to get it into a “working” / debuggable state? Currently when I load it (https://rryfbw.sse.codesandbox.io) I see: image

0reactions
RobinMalfaitcommented, Mar 2, 2022

@bollingerdorian not sure, but that doesn’t sound like an ideal solution to me 🤔. I wonder if it makes more sense to only have 1 Dialog per kind (e.g.: confirmation dialog) and swap out the contents with the correct data based on the item you want to remove.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Please help me set up a Context Menu in an AlertDialog
I have a button that pulls up an AlertDialog populated with saved entries that include Name and Price. Right now, I can click...
Read more >
Modal Dialog Example | APG | WAI - W3C
If the validation message is visible and the focus is on the help link, then the focus may not be visible. The beginning...
Read more >
Window.confirm() - Web APIs - MDN Web Docs
confirm () instructs the browser to display a dialog with an optional message, and to wait until the user either confirms or cancels...
Read more >
confirm option on UI action context menu - ServiceNow
Hi all, below code I am using for create Problem context menu. ... if(confirm("Please check whether workaround is found or not")==true).
Read more >
Dialogs - Android Developers
A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill...
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