CaptainCodeman / svelte-headlessui

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

How to make a dialog non-closable? #30

Closed marchellodev closed 1 year ago

marchellodev commented 1 year ago

Hello, how do I make it so that the opened dialog can only be closed with me manually evoking dialog.close()? The library's dialog component uses only the Transition component (not Dialog like in the official headlessui implementation) so I have no idea how to do this.

CaptainCodeman commented 1 year ago

Remove the backdrop or at least any on:click={dialog.close} that will cause it to close when you click on it (i.e. outside of the dialog).

I think it would still allow escape to close, not sure you'd want to prevent that?

marchellodev commented 1 year ago

Some dialogs (for example, a loading dialog) should be forced and user should not be able to dismiss them in any way

CaptainCodeman commented 1 year ago

I don't think that's really a dialog though, more of a splash / progress display. Even if it might happen to be styled in a similar way, a proper dialog used for input / action should always be cancellable.

If using something means disabling and removing all the features of that thing, it's possibly a sign that it's being mis-used.