Skip to content

Commit 5076f23

Browse files
committed
Close popup when blurred and make sure that shift-tab when popup is open
skips the trigger.
1 parent 4547da1 commit 5076f23

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tests/visual/menu/popup.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ $.widget( "ui.popup", {
3535
this.element
3636
.addClass("ui-popup")
3737
this._close();
38-
38+
3939
this._bind(this.options.trigger, {
4040
click: function( event ) {
4141
event.preventDefault();
@@ -46,6 +46,10 @@ $.widget( "ui.popup", {
4646
}
4747
});
4848

49+
this._bind(this.element, {
50+
blur: "_close"
51+
});
52+
4953
this._bind({
5054
keyup: function( event ) {
5155
if (event.keyCode == $.ui.keyCode.ESCAPE && this.element.is( ":visible" )) {
@@ -94,6 +98,10 @@ $.widget( "ui.popup", {
9498
.attr( "aria-expanded", true )
9599
.position( position )
96100
.focus();
101+
102+
// take trigger out of tab order to allow shift-tab to skip trigger
103+
this.options.trigger.attr("tabindex", -1);
104+
97105
this.open = true;
98106
this._trigger( "open", event );
99107
},
@@ -103,6 +111,9 @@ $.widget( "ui.popup", {
103111
.hide()
104112
.attr( "aria-hidden", true )
105113
.attr( "aria-expanded", false );
114+
115+
this.options.trigger.attr("tabindex", 0);
116+
106117
this.open = false;
107118
this._trigger( "close", event );
108119
}

0 commit comments

Comments
 (0)