File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,9 @@ function selectTab(tabContainer: TabContainerElement, index: number) {
78
78
}
79
79
for ( const panel of panels ) {
80
80
panel . hidden = true
81
- panel . setAttribute ( 'tabindex' , '0' )
81
+ if ( ! panel . hasAttribute ( 'tabindex' ) && ! panel . hasAttribute ( 'data-tab-container-no-tabstop' ) ) {
82
+ panel . setAttribute ( 'tabindex' , '0' )
83
+ }
82
84
}
83
85
84
86
selectedTab . setAttribute ( 'aria-selected' , 'true' )
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ describe('tab-container', function() {
26
26
<div role="tabpanel" hidden>
27
27
Panel 2
28
28
</div>
29
- <div role="tabpanel" hidden>
29
+ <div role="tabpanel" hidden data-tab-container-no-tabstop >
30
30
Panel 3
31
31
</div>
32
32
</tab-container>
@@ -94,6 +94,17 @@ describe('tab-container', function() {
94
94
assert . equal ( counter , 1 )
95
95
} )
96
96
97
+ it ( "panels that don't have a `data-tab-container-no-tabstop` attribute have tabindex with value '0'" , function ( ) {
98
+ const tabs = document . querySelectorAll ( 'button' )
99
+ const panels = document . querySelectorAll ( '[role="tabpanel"]' )
100
+
101
+ tabs [ 1 ] . click ( )
102
+
103
+ assert . equal ( panels [ 0 ] . getAttribute ( 'tabindex' ) , '0' )
104
+ assert . equal ( panels [ 1 ] . getAttribute ( 'tabindex' ) , '0' )
105
+ assert ( ! panels [ 2 ] . hasAttribute ( 'tabindex' ) )
106
+ } )
107
+
97
108
it ( 'the aria-selected attribute is set to "false" for all tabs that don\'t have a aria-selected attribute' , function ( ) {
98
109
for ( const tab of document . querySelectorAll ( '[role="tab"]:not([aria-selected="true"])' ) ) {
99
110
assert . equal ( tab . getAttribute ( 'aria-selected' ) , 'false' )
You can’t perform that action at this time.
0 commit comments