Skip to content

Commit

Permalink
Fix the collapsed state of admonitions containing tables.
Browse files Browse the repository at this point in the history
  • Loading branch information
rblank committed Dec 7, 2024
1 parent d4950f7 commit d5edf37
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion tdoc/common/static/tdoc/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ domLoaded.then(() => {
}
});

// Handle admonition expansion.
// Handle admonition expansion. The button is needed to enable keyboard focus.
domLoaded.then(() => {
for (const el of document.querySelectorAll('.admonition.dropdown')) {
const title = el.querySelector('.admonition-title')
title.addEventListener('click', () => {
el.classList.toggle('expand');
});
// Enable keyboard navigation.
const btn = title.appendChild(element('<button></button>'));
btn.addEventListener('click', (e) => {
el.classList.toggle('expand');
Expand Down
6 changes: 4 additions & 2 deletions tdoc/common/static/tdoc/styles.css.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ blockquote div > p:has(+ p.attribution) {
}
.admonition.dropdown .admonition-title button {
position: absolute;
right: 0.6rem;
right: 0;
outline: none;
border: none;
padding: 0;
Expand All @@ -59,12 +59,14 @@ blockquote div > p:has(+ p.attribution) {
margin-bottom: 0;
}
.admonition.dropdown:not(.expand) .admonition-title ~ * {
display: block;
margin: 0;
border: none;
padding: 0;
height: 0;
visibility: hidden;
opacity: 0;
overflow: hidden;
opacity: 0;
}

/* Iframes */
Expand Down

0 comments on commit d5edf37

Please sign in to comment.