SC.warn, broken behavior when providing Dialog properties

We had a bit of code that did something like this:

    public static final void handleError(final String msg) {
        Dialog dialog = new Dialog();
        dialog.setWidth(500);
        dialog.setHeight(200);
        dialog.setCanDragReposition(true);
        dialog.setDragAppearance(DragAppearance.TARGET);
        dialog.setIsModal(true);
        dialog.setShowModalMask(true);
        dialog.centerInPage();
        SC.warn("Error", msg, new BooleanCallback() {
            @Override
            public void execute(final Boolean value) {
                // do stuff
            }
        }, dialog);
    }

We had a bug in our code that resulted in the above method being called twice, which resulted in two of those SC.warn() calls. The user would only see one dialog, which isn’t surprising, as I read here that SC.warn() reuses the same global dialog. What was surprising is that once we OK’d the dialog, the application lost focus. That is, we could no longer click on anything or type anywhere.

If we changed the above code to not receive a dialog instance, e.g.:

       SC.warn(msg);

Then we did not experience the broken behavior post dialog-close.

What we ended up doing was to create one instance of Dialog() during our class’s constructor, and pass that same instance to the SC.warn() call, instead of creating an instance each time.

Not sure if this is a bug, but thought it would be good to share.

Cheers,

Alex