@@ -176,7 +176,8 @@ $.widget( "ui.tabs", {
176
176
} ,
177
177
178
178
_tabKeydown : function ( event ) {
179
- var focusedTab = $ ( this . document [ 0 ] . activeElement ) . closest ( "li" ) ,
179
+ var focusedAnchor = $ ( this . document [ 0 ] . activeElement ) . closest ( "a" ) ,
180
+ focusedTab = focusedAnchor . closest ( "li" ) ,
180
181
selectedIndex = this . tabs . index ( focusedTab ) ,
181
182
goingForward = true ;
182
183
@@ -202,14 +203,12 @@ $.widget( "ui.tabs", {
202
203
break ;
203
204
case $ . ui . keyCode . SPACE :
204
205
205
- // Activate only, no collapsing
206
206
event . preventDefault ( ) ;
207
207
clearTimeout ( this . activating ) ;
208
208
this . _activate ( selectedIndex ) ;
209
209
return ;
210
210
case $ . ui . keyCode . ENTER :
211
211
212
- // Toggle (cancel delayed activation, allow collapsing)
213
212
event . preventDefault ( ) ;
214
213
clearTimeout ( this . activating ) ;
215
214
@@ -228,11 +227,8 @@ $.widget( "ui.tabs", {
228
227
// Navigating with control/command key will prevent automatic activation
229
228
if ( ! event . ctrlKey && ! event . metaKey ) {
230
229
231
- // Update aria-selected immediately so that AT think the tab is already selected.
232
- // Otherwise AT may confuse the user by stating that they need to activate the tab,
233
- // but the tab will already be activated by the time the announcement finishes.
234
- focusedTab . attr ( "aria-selected" , "false" ) ;
235
- this . tabs . eq ( selectedIndex ) . attr ( "aria-selected" , "true" ) ;
230
+ focusedAnchor . attr ( "aria-selected" , "false" ) ;
231
+ this . anchors . eq ( selectedIndex ) . attr ( "aria-selected" , "true" ) ;
236
232
237
233
this . activating = this . _delay ( function ( ) {
238
234
this . option ( "active" , selectedIndex ) ;
@@ -286,7 +282,7 @@ $.widget( "ui.tabs", {
286
282
287
283
_focusNextTab : function ( index , goingForward ) {
288
284
index = this . _findNextTab ( index , goingForward ) ;
289
- this . tabs . eq ( index ) . trigger ( "focus" ) ;
285
+ this . anchors . eq ( index ) . trigger ( "focus" ) ;
290
286
return index ;
291
287
} ,
292
288
@@ -413,15 +409,15 @@ $.widget( "ui.tabs", {
413
409
414
410
this . tabs = this . tablist . find ( "> li:has(a[href])" )
415
411
. attr ( {
416
- role : "tab" ,
417
- tabIndex : - 1
412
+ role : "presentation"
418
413
} ) ;
419
414
this . _addClass ( this . tabs , "ui-tabs-tab" , "ui-state-default" ) ;
420
415
421
416
this . anchors = this . tabs . map ( function ( ) {
422
417
return $ ( "a" , this ) [ 0 ] ;
423
418
} )
424
419
. attr ( {
420
+ role : "tab" ,
425
421
tabIndex : - 1
426
422
} ) ;
427
423
this . _addClass ( this . anchors , "ui-tabs-anchor" ) ;
@@ -437,16 +433,6 @@ $.widget( "ui.tabs", {
437
433
// Inline tab
438
434
if ( that . _isLocal ( anchor ) ) {
439
435
440
- // The "scrolling to a fragment" section of the HTML spec:
441
- // https://html.spec.whatwg.org/#scrolling-to-a-fragment
442
- // uses a concept of document's indicated part:
443
- // https://html.spec.whatwg.org/#the-indicated-part-of-the-document
444
- // Slightly below there's an algorithm to compute the indicated
445
- // part:
446
- // https://html.spec.whatwg.org/#the-indicated-part-of-the-document
447
- // First, the algorithm tries the hash as-is, without decoding.
448
- // Then, if one is not found, the same is attempted with a decoded
449
- // hash. Replicate this logic.
450
436
selector = anchor . hash ;
451
437
panelId = selector . substring ( 1 ) ;
452
438
panel = that . element . find ( "#" + CSS . escape ( panelId ) ) ;
@@ -455,11 +441,8 @@ $.widget( "ui.tabs", {
455
441
panel = that . element . find ( "#" + CSS . escape ( panelId ) ) ;
456
442
}
457
443
458
- // remote tab
459
444
} else {
460
445
461
- // If the tab doesn't already have aria-controls,
462
- // generate an id by using a throw-away element
463
446
panelId = tab . attr ( "aria-controls" ) || $ ( { } ) . uniqueId ( ) [ 0 ] . id ;
464
447
selector = "#" + panelId ;
465
448
panel = that . element . find ( selector ) ;
@@ -554,7 +537,7 @@ $.widget( "ui.tabs", {
554
537
this . _on ( this . tabs , { keydown : "_tabKeydown" } ) ;
555
538
this . _on ( this . panels , { keydown : "_panelKeydown" } ) ;
556
539
557
- this . _focusable ( this . tabs ) ;
540
+ this . _focusable ( this . anchors ) ;
558
541
this . _hoverable ( this . tabs ) ;
559
542
} ,
560
543
0 commit comments