Skip to content
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

Dialog isn't modal like mentioned in the docs #132

Closed
cheak1974 opened this issue Oct 22, 2022 · 2 comments
Closed

Dialog isn't modal like mentioned in the docs #132

cheak1974 opened this issue Oct 22, 2022 · 2 comments
Milestone

Comments

@cheak1974
Copy link

Hi Everybody,

is there a possibility to make the dialog really modal?

The API Reference claims that it is modal but the dialog can be closed at any time by clicking onto an area outside the dialog. This is not really what I call modal. The dialog should stay open until the user was using the dedicated method to close the dialog (by calling the the .close() method, e.g. bound to a button).

Maybe you consider to add an "is_modal" modifier to the constructor of the dialog class (with default value set to "False" to keep the original behaviour) and suppress the closing of the dialog by clicking somewhere.

@falkoschindler
Copy link
Contributor

Quasar's "persistent" prop might be what you're looking for:

Description: User cannot dismiss Dialog if clicking outside of it or hitting ESC key; Also, an app route change won't dismiss it

https://quasar.dev/vue-components/dialog

So the modified example would look like this:

from nicegui import ui

with ui.dialog().props('persistent') as dialog, ui.card():
    ui.label('Hello world!')
    ui.button('Close', on_click=dialog.close)

ui.button('Open a dialog', on_click=dialog.open)

ui.run()

Actually, I wasn't aware that "modal" dialogs are supposed to stay open when clicking in the background. We should update the documentation.

@cheak1974
Copy link
Author

Hi Falko,

I am not that experienced in Quasar, so your help is very much appreciated and yes, the "persistent" prop did the trick.

I think that not only me could find this feature useful so maybe it is a good idea to mention this in the API reference as you proposed. Indeed a "modal" dialog is one the user of the UI can not evade and he has to be interact with before anything else can happen.
https://en.wikipedia.org/wiki/Modal_window

Thank you very much.
Chris

@rodja rodja added this to the v0.9.20 milestone Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants