diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 6d13935de..0d48c1cf7 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -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