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] Modeless dialog does not honor close on outside click #7778

Open
knoobie opened this issue Sep 6, 2024 · 4 comments
Open

[dialog] Modeless dialog does not honor close on outside click #7778

knoobie opened this issue Sep 6, 2024 · 4 comments
Labels
documentation Improvements or additions to documentation needs discussion No decision yet, discussion needed vaadin-dialog

Comments

@knoobie
Copy link
Contributor

knoobie commented Sep 6, 2024

Description

Using modeless (setModal(false) does not honor closeOnOutsideClick and stays open.

Expected outcome

Dialog closes when clicking outside.

Minimal reproducible example

        var dialog = new Dialog();
        dialog.setModal(false);
        dialog.setCloseOnOutsideClick(true);
        dialog.add(new Paragraph("Lorem Ipsum"));
        dialog.open();

Environment

Vaadin version(s): 24.4.10

Browsers

All

@web-padawan
Copy link
Member

This is kind of by design as the "modeless" overlay doesn't use global outside click / Esc key listeners:

if (!modeless) {
if (this.opened) {
this._addGlobalListeners();
this._enterModalState();
}
} else {
this._removeGlobalListeners();
this._exitModalState();
}

We did have to add some workarounds for it especially custom outside click listener for vaadin-context-menu.

@knoobie
Copy link
Contributor Author

knoobie commented Sep 6, 2024

If this is not a bug.. it probably has to be documented on the flow side on either modal or closeOnOutsideClick - I was kinda suprised by this :) We use setModal(false) often because of the "problems" with server-side modality; which renders the closeOnOutsideClick flag "useless".

@web-padawan web-padawan added documentation Improvements or additions to documentation vaadin-dialog labels Sep 6, 2024
@TatuLund
Copy link
Contributor

TatuLund commented Sep 6, 2024

Note, you can have modal dialog and disable the server side modality using API in UI class.

@sissbruecker
Copy link
Contributor

Something is wrong if people start using non-modal dialogs to work around server-side modality. Maybe there should be a more obvious API on the component level to disable it.

Right now disabling it is not straightforward:

  • It requires you to add the dialog to the UI manually, otherwise the auto-add functionality will make the dialog a server-side modal in a before client response hook
  • You must disable the server-side modality each time after opening the dialog

For comparison, this works:

add(dialog);
dialog.open();
ui.setChildComponentModal(dialog, false);

And these don't:

dialog.open();
ui.setChildComponentModal(dialog, false);
add(dialog);
ui.setChildComponentModal(dialog, false);
dialog.open();

@yuriy-fix yuriy-fix added the needs discussion No decision yet, discussion needed label Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation needs discussion No decision yet, discussion needed vaadin-dialog
Projects
None yet
Development

No branches or pull requests

5 participants