tabs: nested tabs content is not displayed #468

This commit is contained in:
Sören Weber 2023-02-07 18:06:34 +01:00
parent fbdb71e6fa
commit 56bc99b79a
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
3 changed files with 20 additions and 17 deletions

View file

@ -18,7 +18,7 @@
{{- range $idx, $tab := $tabs }}
<div
data-tab-item="{{ .name }}"
class="tab-item {{ cond (eq $idx 0) "active" ""}}"
class="tab-content-text {{ cond (eq $idx 0) "active" ""}}"
>
{{ .content | safeHTML }}
</div>

View file

@ -1,3 +1,7 @@
#body .tab-panel{
margin-bottom: 1.5rem;
margin-top: 1.5rem;
}
#body .tab-nav-button{
background-color: rgba( 134, 134, 134, .166 );
border-color: rgba( 134, 134, 134, .333 );
@ -32,10 +36,6 @@
#body .tab-nav-button:not(.active) span{
opacity: .8;
}
#body .tab-panel {
margin-bottom: 1.5rem;
margin-top: 1.5rem;
}
#body .tab-content{
background-color: transparent;
border-color: rgba( 134, 134, 134, .333 );
@ -48,15 +48,15 @@
padding: 8px;
z-index: 10;
}
#body .tab-content .tab-item{
#body .tab-content-text{
display: none;
}
#body .tab-content .tab-item.active{
#body .tab-content-text.active{
display: block;
}
#body .tab-item pre{
#body .tab-content-text pre{
margin-bottom: 0;
margin-top: 0;
}

View file

@ -59,17 +59,20 @@ function switchTab(tabGroup, tabId) {
return !!e.querySelector( '[data-tab-item="'+tabId+'"]' );
});
var allTabItems = tabs && tabs.reduce( function( a, e ){
return a.concat( Array.from( e.querySelectorAll( '.tab-nav-button, .tab-item' ) ) );
return a.concat( Array.from( e.querySelectorAll( '[data-tab-item]' ) ).filter( function( es ){
return es.parentNode.parentNode == e;
}) );
}, [] );
var targetTabItems = tabs && tabs.reduce( function( a, e ){
return a.concat( Array.from( e.querySelectorAll( '[data-tab-item="'+tabId+'"]' ) ) );
return a.concat( Array.from( e.querySelectorAll( '[data-tab-item="'+tabId+'"]' ) ).filter( function( es ){
return es.parentNode.parentNode == e;
}) );
}, [] );
// if event is undefined then switchTab was called from restoreTabSelection
// so it's not a button event and we don't need to safe the selction or
// prevent page jump
var isButtonEvent = event && event.target && event.target.getBoundingClientRect;
if(isButtonEvent){
// save button position relative to viewport
var yposButton = event.target.getBoundingClientRect().top;