Skip to content

Commit 56bc99b

Browse files
committed
tabs: nested tabs content is not displayed matcornic#468
1 parent fbdb71e commit 56bc99b

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

layouts/partials/shortcodes/tabs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
{{- range $idx, $tab := $tabs }}
1919
<div
2020
data-tab-item="{{ .name }}"
21-
class="tab-item {{ cond (eq $idx 0) "active" ""}}"
21+
class="tab-content-text {{ cond (eq $idx 0) "active" ""}}"
2222
>
2323
{{ .content | safeHTML }}
2424
</div>

static/css/tabs.css

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
#body .tab-nav-button {
1+
#body .tab-panel{
2+
margin-bottom: 1.5rem;
3+
margin-top: 1.5rem;
4+
}
5+
#body .tab-nav-button{
26
background-color: rgba( 134, 134, 134, .166 );
37
border-color: rgba( 134, 134, 134, .333 );
48
border-radius: 4px 4px 0 0;
@@ -16,27 +20,23 @@
1620
padding: 6px 12px;
1721
position: relative;
1822
}
19-
#body .tab-nav-button.direction-rtl {
23+
#body .tab-nav-button.direction-rtl{
2024
float: right;
2125
}
2226

23-
#body .tab-nav-button:first-child {
27+
#body .tab-nav-button:first-child{
2428
margin-inline-start: 9px;
2529
}
26-
#body .tab-nav-button:not(.active) {
30+
#body .tab-nav-button:not(.active){
2731
border-bottom-color: rgba( 134, 134, 134, .1 );
2832
margin-top: 8px;
2933
padding-bottom: 2px !important;
3034
padding-top: 2px !important;
3135
}
32-
#body .tab-nav-button:not(.active) span {
36+
#body .tab-nav-button:not(.active) span{
3337
opacity: .8;
3438
}
35-
#body .tab-panel {
36-
margin-bottom: 1.5rem;
37-
margin-top: 1.5rem;
38-
}
39-
#body .tab-content {
39+
#body .tab-content{
4040
background-color: transparent;
4141
border-color: rgba( 134, 134, 134, .333 );
4242
border-style: solid;
@@ -48,15 +48,15 @@
4848
padding: 8px;
4949
z-index: 10;
5050
}
51-
#body .tab-content .tab-item{
51+
#body .tab-content-text{
5252
display: none;
5353
}
5454

55-
#body .tab-content .tab-item.active{
55+
#body .tab-content-text.active{
5656
display: block;
5757
}
5858

59-
#body .tab-item pre{
59+
#body .tab-content-text pre{
6060
margin-bottom: 0;
6161
margin-top: 0;
6262
}

static/js/theme.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,20 @@ function switchTab(tabGroup, tabId) {
5959
return !!e.querySelector( '[data-tab-item="'+tabId+'"]' );
6060
});
6161
var allTabItems = tabs && tabs.reduce( function( a, e ){
62-
return a.concat( Array.from( e.querySelectorAll( '.tab-nav-button, .tab-item' ) ) );
62+
return a.concat( Array.from( e.querySelectorAll( '[data-tab-item]' ) ).filter( function( es ){
63+
return es.parentNode.parentNode == e;
64+
}) );
6365
}, [] );
6466
var targetTabItems = tabs && tabs.reduce( function( a, e ){
65-
return a.concat( Array.from( e.querySelectorAll( '[data-tab-item="'+tabId+'"]' ) ) );
67+
return a.concat( Array.from( e.querySelectorAll( '[data-tab-item="'+tabId+'"]' ) ).filter( function( es ){
68+
return es.parentNode.parentNode == e;
69+
}) );
6670
}, [] );
6771

6872
// if event is undefined then switchTab was called from restoreTabSelection
6973
// so it's not a button event and we don't need to safe the selction or
7074
// prevent page jump
7175
var isButtonEvent = event && event.target && event.target.getBoundingClientRect;
72-
7376
if(isButtonEvent){
7477
// save button position relative to viewport
7578
var yposButton = event.target.getBoundingClientRect().top;

0 commit comments

Comments
 (0)