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

ConfirmDialog setCloseOnOutsideClick #8126

Open
sveinnetnordic opened this issue Nov 8, 2024 · 4 comments
Open

ConfirmDialog setCloseOnOutsideClick #8126

sveinnetnordic opened this issue Nov 8, 2024 · 4 comments
Labels

Comments

@sveinnetnordic
Copy link

Describe your motivation

Started to replace my old component MyConfirmDialog, which extends Dialog, with the nice ConfirmDialog. Could not find setCloseOnOutsideClick, which I use for Info/Warning.

Describe the solution you'd like

Add

public void setCloseOnOutsideClick(boolean closeOnOutsideClick) {
        getElement().setProperty("noCloseOnOutsideClick", !closeOnOutsideClick);
    }

Describe alternatives you've considered

Currently using this hack:

ConfirmDialog().also {
            it.open()
            it.element.executeJs("overlay.shadowRoot.getElementById('backdrop').onclick = ()=>this.opened=false")
        }

Additional context

No response

@rolfsmeds
Copy link
Contributor

The ConfirmDialog is not really designed to be used for anything that can just be dismissed like that without making an explicit choice – it's intended for use cases where the user actually needs to confirm or cancel an operation. I would recommend using the normal Dialog for this instead.

@sveinnetnordic
Copy link
Author

I agree!

I would be nice to have the possibility to have a protected void setCloseOnOutsideClick(boolean closeOnOutsideClick) in ConfirmDialog

public class InfoDialog extends ConfirmDialog {
    @Override
    public void setCloseOnOutsideClick(boolean closeOnOutsideClick) {
        super.setCloseOnOutsideClick(closeOnOutsideClick);
    }
}

Then I could delete my MyConfirmDialog extends Dialog, because ConfirmDialog has everything I need.

I could also use the ugly executeJs above in InfoDialog.setCloseOnOutsideClick, but not so nice. It is maybe a more pretty way to close the dialog on outside click?

@rolfsmeds
Copy link
Contributor

Is there a particular reason why you want to use ConfirmDialog instead of Dialog for use cases that are not about actually confirming something?

@sveinnetnordic
Copy link
Author

sveinnetnordic commented Nov 14, 2024

This is a light weight message. User forgot that parent course should be set first. Just clicking outside is enough. Was thinking to use Notification, but think ConfirmDialog is best. The MyConfirmDialog has setCloseOnOutsideClick, just trying to do the same. Not a big deal! If overlay.shadowRoot.getElementById... stops working user need to click Confirm...
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants