File tree 4 files changed +26
-3
lines changed
4 files changed +26
-3
lines changed Original file line number Diff line number Diff line change 14
14
role =" tab"
15
15
aria-controls ={{ tab.target }}
16
16
aria-selected ={{ if tab.isCurrent " true" " false" }}
17
- {{ on " click" (fn tab .onClickTab tab )}}
17
+ {{ on " click" (fn this .onClickTab tab )}}
18
18
>{{ capitalize tab.label }} </button >
19
19
</li >
20
20
{{ /each }}
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ import Component from '@glimmer/component' ;
7
+ import { action } from '@ember/object' ;
8
+
9
+ export default class DocPageTabsComponent extends Component {
10
+ @action
11
+ onClickTab ( tab ) {
12
+ // Invoke the callback function if it's provided as argument
13
+ if ( typeof tab . onClickTab === 'function' ) {
14
+ tab . onClickTab ( tab ) ;
15
+ }
16
+
17
+ // Set focus on tab clicked
18
+ let tabElement = document . getElementById ( tab . id ) ;
19
+ tabElement . focus ( ) ;
20
+ }
21
+ }
Original file line number Diff line number Diff line change @@ -100,10 +100,13 @@ export default class ApplicationController extends Controller {
100
100
// Disable transition validation if we're transitioning to the same page
101
101
// and the page is has a filter functionality based on `queryParams`
102
102
// namely the Icon library or the Tokens page
103
+ // or if the transition is between tabs on the same page
104
+ let hasTabs = document . querySelector ( '.doc-page-tabs' ) != null ;
103
105
if (
104
106
transition . from . params . path === transition . to . params . path &&
105
107
( transition . from . params . path === 'icons/library' ||
106
- transition . from . params . path === 'foundations/tokens' )
108
+ transition . from . params . path === 'foundations/tokens' ||
109
+ hasTabs )
107
110
) {
108
111
return false ;
109
112
} else {
Original file line number Diff line number Diff line change @@ -246,7 +246,6 @@ export default class ShowController extends Controller {
246
246
}
247
247
248
248
// TABS
249
- // ?? CAN WE EXPLICITLY SET FOCUS ON THE TAB WHEN IT IS SET TO CURRENT?
250
249
this . tabs . forEach ( ( tab ) => {
251
250
set ( tab , 'isCurrent' , tab . index === current ) ;
252
251
} ) ;
You can’t perform that action at this time.
0 commit comments