Skip to content

Commit 2803417

Browse files
committed
Tooltip: Handle ESCAPE key event to close tooltip when target has focus.
1 parent bc93b3f commit 2803417

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

ui/jquery.ui.tooltip.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,14 @@ $.widget( "ui.tooltip", {
148148

149149
this._bind( target, {
150150
mouseleave: "close",
151-
blur: "close"
151+
blur: "close",
152+
keyup: function( event ) {
153+
if ( event.keyCode == $.ui.keyCode.ESCAPE ) {
154+
var fakeEvent = $.Event(event);
155+
fakeEvent.currentTarget = target[0];
156+
this.close( fakeEvent, true );
157+
}
158+
}
152159
});
153160
},
154161

@@ -176,7 +183,7 @@ $.widget( "ui.tooltip", {
176183
delete that.tooltips[ this.id ];
177184
});
178185

179-
target.unbind( "mouseleave.tooltip blur.tooltip" );
186+
target.unbind( "mouseleave.tooltip blur.tooltip keyup.tooltip" );
180187

181188
this._trigger( "close", event, { tooltip: tooltip } );
182189
},

0 commit comments

Comments
 (0)