com.vaadin.flow.component.confirmdialog.ConfirmDialog.setCancelButton(...) not working as expected

Hi all! I have the following code:

` private void logout(ClickEvent logoutButtonClickEvent) {
ConfirmDialog logoutDialog = new ConfirmDialog();

    logoutDialog.setHeader("Confirmation required");
    logoutDialog.setText("Do you really want to leave?");
    logoutDialog.setConfirmButton(createLogoutConfirmButton());
    logoutDialog.setCancelButton(createLogoutCancelButton());

    logoutDialog.open();
}

private Button createLogoutConfirmButton() {
    Button logoutConfirmButton = new Button();

    logoutConfirmButton.setText("Yes");
    logoutConfirmButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY, ButtonVariant.LUMO_ERROR);

    logoutConfirmButton.addClickListener(logoutConfirmButtonClickEvent -> securityService.logout());

    return logoutConfirmButton;
}

private Button createLogoutCancelButton() {
    Button logoutCancelButton = new Button();

    logoutCancelButton.setText("No");
    logoutCancelButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY, ButtonVariant.LUMO_SUCCESS);

    return logoutCancelButton;
}`

The problem is that there is no “No” button in the confirmation dialog. And I can’t understand why. Can anyone tell me if I’m doing something wrong or is this a bug?
Spring Boot 3.0.5, Vaadin 24.0.3
image.png

com.vaadin.flow.component.confirmdialog.ConfirmDialog.setCancelButton(…) not working as expected

You’ll need to add logoutDialog.setCancelable(true);

Thanks, but I think this should be fixed in a future version of Vaadin… I can’t imagine any case where setting the cancel button didn’t imply that the dialog should be cancelable. I think dialog.setCancelButton(…) should call dialog.setCancelable(true) internally.

Feel free to create a GitHub issue about it!