Dialog by default closes on return keypress with success status. However, there doesn't seem to be a good way to prevent this if you want to use an ajax request to determine the success.
Example: I have a sign-in dialog that I want to appear throughout the site and have different success callbacks in some cases so I observe the container's ui:dialog:close:after event and success means the sign-in was successful and otherwise not. But if the user presses enter the dialog is closed with success and there is no way for my callback to distinguish a success from my ajax callback versus the return keypress.
Suggestion: at minimum, add a closeOnReturn option so this behavior can be easily disabled. Otherwise, it seems like the most logical action for the return keypress would be to trigger the click action of the primary button so that the actions attached to the button are executed instead of just always closing the window.
What if you attached everything to the ui:dialog:before:close event instead? (There isn't a success property on the event, but there probably should be anyway.)
I want to prevent the dialog from closing in case the ajax response reports an error so teh user can try again. To do that I'd either have to use synchronous requests, or use some silly flags to indicate the close state. The three possible states in this case which all have different results are: success, failure, cancelled.
Adding a closeOnReturn option is consistent with the current closeOnEscape option and it doesn't break backwards compatibility. Assuming that the dialog should always be closed with a success state when the enter key is pressed makes the code really ugly when that is an incorrect assumption.
That's fair. I'll add a closeOnReturn option.