Dialog: ESC key event was not being canceled after it was handled (Fixed #4922 window.location.reload() doesn't work in dialog's close callback when it's triggered by ESC in Firefox)

This commit is contained in:
Brant Burnett 2010-02-22 18:39:12 +00:00
parent e2202847c6
commit 350853179f

View File

@ -66,8 +66,12 @@ $.widget("ui.dialog", {
// setting tabIndex makes the div focusable
// setting outline to 0 prevents a border on focus in Mozilla
.attr('tabIndex', -1).css('outline', 0).keydown(function(event) {
(options.closeOnEscape && event.keyCode
&& event.keyCode == $.ui.keyCode.ESCAPE && self.close(event));
if (options.closeOnEscape && event.keyCode
&& event.keyCode == $.ui.keyCode.ESCAPE) {
self.close(event);
event.preventDefault();
}
})
.attr({
role: 'dialog',
@ -614,8 +618,12 @@ $.extend($.ui.dialog.overlay, {
// allow closing by pressing the escape key
$(document).bind('keydown.dialog-overlay', function(event) {
(dialog.options.closeOnEscape && event.keyCode
&& event.keyCode == $.ui.keyCode.ESCAPE && dialog.close(event));
if (dialog.options.closeOnEscape && event.keyCode
&& event.keyCode == $.ui.keyCode.ESCAPE) {
dialog.close(event);
event.preventDefault();
}
});
// handle window resize