]> source.dussan.org Git - jquery-ui.git/commitdiff
Dialog: Don't focus dialog when mousedown is on close button. Fixes #8838 - Dialog...
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Mon, 26 Nov 2012 09:08:34 +0000 (10:08 +0100)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Mon, 26 Nov 2012 09:28:25 +0000 (10:28 +0100)
ui/jquery.ui.dialog.js

index bcfc6f07c7921d4a1151a4dbbbb5056e3e3a96ea..5eb3e2aca824de2b34d05026265789afda431c41 100644 (file)
@@ -321,9 +321,14 @@ $.widget("ui.dialog", {
                        .addClass( "ui-dialog-titlebar  ui-widget-header ui-corner-all  ui-helper-clearfix" )
                        .prependTo( this.uiDialog );
                this._on( this.uiDialogTitlebar, {
-                       mousedown: function() {
-                               // Dialog isn't getting focus when dragging (#8063)
-                               this.uiDialog.focus();
+                       mousedown: function( event ) {
+                               // Don't prevent click on close button (#8838)
+                               // Focusing a dialog that is partially scrolled out of view
+                               // causes the browser to scroll it into view, preventing the click event
+                               if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
+                                       // Dialog isn't getting focus when dragging (#8063)
+                                       this.uiDialog.focus();
+                               }
                        }
                });