CaptainCodeman / svelte-headlessui

HeadlessUI components for Svelte
https://captaincodeman.github.io/svelte-headlessui/
MIT License
529 stars 25 forks source link

Prevent close and onClose event? #85

Closed hernandp-nimble closed 1 month ago

hernandp-nimble commented 6 months ago

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

CaptainCodeman commented 6 months ago

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

hernandp-nimble commented 6 months ago

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

CaptainCodeman commented 6 months ago

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.

zinkkrysty commented 1 month ago

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.

CaptainCodeman commented 1 month ago

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

zinkkrysty commented 1 month ago

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

Yes, that's correct.