Skip to content

Commit 2801705

Browse files
committed
Popup: Fix the reopens-issue when clicking the trigger while popup is
visible, while still handling an actualy blur properly.
1 parent 476777f commit 2801705

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

tests/visual/menu/popup.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ $.widget( "ui.popup", {
3939
this._bind(this.options.trigger, {
4040
keydown: function( event ) {
4141
// prevent space-to-open to scroll the page
42+
// TODO do this only for a:ui-button?
4243
if (event.keyCode == $.ui.keyCode.SPACE) {
4344
event.preventDefault()
4445
}
@@ -50,16 +51,22 @@ $.widget( "ui.popup", {
5051
return;
5152
}
5253
var that = this;
54+
clearTimeout( this.closeTimer );
5355
setTimeout(function() {
5456
that.open( event );
5557
}, 1);
5658
}
5759
});
5860

5961
this._bind(this.element, {
60-
// TODO also triggered when open and clicking the trigger again
61-
// figure out how to close in that case, while still closing on regular blur
62-
//blur: "close"
62+
blur: function( event ) {
63+
var that = this;
64+
// use a timer to allow click to clear it and letting that
65+
// handle the closing instead of opening again
66+
that.closeTimer = setTimeout( function() {
67+
that.close( event );
68+
}, 100);
69+
}
6370
});
6471

6572
this._bind({

0 commit comments

Comments
 (0)