@@ -39,12 +39,18 @@ $.widget( "ui.popup", {
39
39
this . _bind ( this . options . trigger , {
40
40
keydown : function ( event ) {
41
41
// prevent space-to-open to scroll the page, only hapens for anchor ui.button
42
- if ( $ ( event . currentTarget ) . is ( "a:ui-button" ) && event . keyCode == $ . ui . keyCode . SPACE ) {
42
+ if ( this . options . trigger . is ( "a:ui-button" ) && event . keyCode == $ . ui . keyCode . SPACE ) {
43
43
event . preventDefault ( )
44
44
}
45
- // TODO handle keydown to open popup? only when not handled by ui.button
46
- //if (event.keyCode == $.ui.keyCode.SPACE) {
47
- //}
45
+ // TODO handle SPACE to open popup? only when not handled by ui.button
46
+ if ( event . keyCode == $ . ui . keyCode . SPACE && this . options . trigger . is ( "a:not(:ui-button)" ) ) {
47
+ this . options . trigger . trigger ( "click" , event ) ;
48
+ }
49
+ // translate keydown to click
50
+ // opens popup and let's tooltip hide itself
51
+ if ( event . keyCode == $ . ui . keyCode . DOWN ) {
52
+ this . options . trigger . trigger ( "click" , event ) ;
53
+ }
48
54
} ,
49
55
click : function ( event ) {
50
56
event . preventDefault ( ) ;
@@ -61,6 +67,7 @@ $.widget( "ui.popup", {
61
67
} ) ;
62
68
63
69
this . _bind ( this . element , {
70
+ // TODO use focusout so that element itself doesn't need to be focussable
64
71
blur : function ( event ) {
65
72
var that = this ;
66
73
// use a timer to allow click to clear it and letting that
@@ -74,9 +81,11 @@ $.widget( "ui.popup", {
74
81
this . _bind ( {
75
82
// TODO only triggerd on element if it can receive focus
76
83
// bind to document instead?
84
+ // either element itself or a child should be focusable
77
85
keyup : function ( event ) {
78
86
if ( event . keyCode == $ . ui . keyCode . ESCAPE && this . element . is ( ":visible" ) ) {
79
87
this . close ( event ) ;
88
+ // TODO move this to close()? would allow menu.select to call popup.close, and get focus back to trigger
80
89
this . options . trigger . focus ( ) ;
81
90
}
82
91
}
@@ -120,6 +129,7 @@ $.widget( "ui.popup", {
120
129
. attr ( "aria-hidden" , false )
121
130
. attr ( "aria-expanded" , true )
122
131
. position ( position )
132
+ // TODO find a focussable child, otherwise put focus on element, add tabIndex=0 if not focussable
123
133
. focus ( ) ;
124
134
125
135
if ( this . element . is ( ":ui-menu" ) ) {
0 commit comments