Skip to content

Closing dialog needs to be equal to clicking the Cancel, not the No button #28

@pbodnar

Description

@pbodnar

The ConfirmDialog should follow the "standard" yes/no/cancel dialogs behavior: when one presses Esc or clicks on the close icon in the dialog, the dialog's method isCancelled() needs to return true. Currently, it always return false (so the client code thinks "No" was pressed) due to setting the null-able isConfirmed variable without looking at whether we are showing the yes/no/cancel variant of the dialog. The listener which needs to be fixed in DefaultConfirmDialogFactory.java:

    // Close listener implementation
    confirm.addCloseListener(new Window.CloseListener() {

        private static final long serialVersionUID = 1971800928047045825L;

        public void windowClose(CloseEvent ce) {

            // Only process if still enabled
            if (confirm.isEnabled()) {
                confirm.setEnabled(false); // avoid double processing
                confirm.setConfirmed(false);
                if (confirm.getListener() != null) {
                    confirm.getListener().onClose(confirm);
                }
            }
        }
    });

The fix (adding one "if") seems to be very easy to do...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions