svelte-headlessui icon indicating copy to clipboard operation
svelte-headlessui copied to clipboard

Prevent close and onClose event?

Open hernandp-nimble opened this issue 1 year ago • 3 comments
trafficstars

It a lot of use cases we want to add functionality when closing as prevent the close whenever a condition is met.

hernandp-nimble avatar Jan 19 '24 13:01 hernandp-nimble

Can you provide more details - which component, and the scenario you'd want to prevent close?

CaptainCodeman avatar Jan 19 '24 16:01 CaptainCodeman

Sorry for the lack of information, I was talking about the dialog. Also nested dialogs render inside each other and cannot be set to absolute if you have relative containers on top. I saw in other libraries they use Portals to manage this better, don't know if that can be a solution

hernandp-nimble avatar Jan 19 '24 17:01 hernandp-nimble

And what is the situation where the user wants to close a dialog, but the system should get to say "nuhuh"? IMO it should always be equivalent to a 'cancel' action.

I'm not a fan of nested dialogs, I think the UX should always be re-thought at that point.

CaptainCodeman avatar Jan 22 '24 19:01 CaptainCodeman

I have also ran into this, as the dialog that we use is a complex dialog, with forms and multiple steps. Because of technical limitations (integrating with 3rd party), we are forced to use a dialog for this interaction, and while I understand this is not the ideal use case of the dialog, the lack of customizability on the close behavior prevents us from using it. It would be a bad user experience if the user accidentally hits escape or clicks outside of the dialog - as they are forced to repeat all the steps to get to the same point. It would be great if your library provided a way to prevent these default actions.

zinkkrysty avatar Jun 03 '24 13:06 zinkkrysty

I see, so you want to protect against accidental closure from them clicking anything but the close button.

CaptainCodeman avatar Jun 03 '24 16:06 CaptainCodeman

I see, so you want to protect against accidental closure from them clicking anything but the close button.

Yes, that's correct.

zinkkrysty avatar Jun 03 '24 19:06 zinkkrysty