File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,7 +78,9 @@ function selectTab(tabContainer: TabContainerElement, index: number) {
7878 }
7979 for ( const panel of panels ) {
8080 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+ }
8284 }
8385
8486 selectedTab . setAttribute ( 'aria-selected' , 'true' )
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ describe('tab-container', function() {
2626 <div role="tabpanel" hidden>
2727 Panel 2
2828 </div>
29- <div role="tabpanel" hidden>
29+ <div role="tabpanel" hidden data-tab-container-no-tabstop >
3030 Panel 3
3131 </div>
3232 </tab-container>
@@ -94,6 +94,17 @@ describe('tab-container', function() {
9494 assert . equal ( counter , 1 )
9595 } )
9696
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+
97108 it ( 'the aria-selected attribute is set to "false" for all tabs that don\'t have a aria-selected attribute' , function ( ) {
98109 for ( const tab of document . querySelectorAll ( '[role="tab"]:not([aria-selected="true"])' ) ) {
99110 assert . equal ( tab . getAttribute ( 'aria-selected' ) , 'false' )
You can’t perform that action at this time.
0 commit comments