File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
layouts/_partials/shortcodes Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 99*/ -}}
1010{{- $tabs := .tabs }}
1111
12+ {{- if eq (len $tabs) 0 -}}
13+ {{ errorf "tabs must have at least one tab" }}
14+ {{- end -}}
15+
1216{{- $enableSync := .enableSync }}
1317
1418{{- /* Create group data for syncing and select the first tab if none is selected. */ -}}
15- {{- $selectFirst := true -}}
19+ {{- $selectedIndex := 0 -}}
1620{{ $dataTabGroup := slice -}}
1721
1822{{- range $i, $item := $tabs -}}
1923 {{- $dataTabGroup = $dataTabGroup | append ($item.name) -}}
2024
2125 {{- if $item.selected -}}
22- {{- $selectFirst = false -}}
26+ {{- $selectedIndex = $i -}}
2327 {{- end -}}
2428{{- end -}}
2529
3741 role ="tab "
3842 type ="button "
3943 aria-controls ="tabs-panel-{{ $globalID }}-{{ $item.id }} "
40- {{- if or $item.selected (and $selectFirst ( eq $i 0)) -}}
44+ {{- if eq $i $selectedIndex -}}
4145 aria-selected ="true "
4246 tabindex ="0 "
4347 data-state ="selected "
5458 class ="hextra-tabs-panel hx:rounded-sm hx:pt-6 hx:hidden hx:data-[state=selected]:block "
5559 id ="tabs-panel-{{ $globalID }}-{{ $item.id }} "
5660 role ="tabpanel "
57- {{- if or $item.selected (and $selectFirst ( eq $i 0)) -}}
61+ {{- if eq $i $selectedIndex -}}
5862 tabindex ="0 "
5963 data-state ="selected "
6064 {{ end -}}
You can’t perform that action at this time.
0 commit comments