Skip to content

Commit 98ca1e2

Browse files
committed
Prevent hidden element in collapse margin sidebar to trigger events
When hiding the sidebar, we change opacity and add overflow hidden, but opacity: 0 does not prevent event to be triggered. Though it has the best performance: https://www.sitepoint.com/hide-elements-in-css/#1opacityandfilteropacity So for the hidden TOC node, we use pointer-events: none to prevent any event to be triggered. https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
1 parent b776ec1 commit 98ca1e2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/resources/formats/html/quarto.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ window.document.addEventListener("DOMContentLoaded", function (_event) {
319319
for (const child of el.children) {
320320
child.style.opacity = 0;
321321
child.style.overflow = "hidden";
322+
child.style.pointerEvents = "none";
322323
}
323324

324325
nexttick(() => {
@@ -360,6 +361,7 @@ window.document.addEventListener("DOMContentLoaded", function (_event) {
360361

361362
const clone = child.cloneNode(true);
362363
clone.style.opacity = 1;
364+
clone.style.pointerEvents = null;
363365
clone.style.display = null;
364366
toggleContents.append(clone);
365367
}
@@ -434,6 +436,7 @@ window.document.addEventListener("DOMContentLoaded", function (_event) {
434436
for (const child of el.children) {
435437
child.style.opacity = 1;
436438
child.style.overflow = null;
439+
child.style.pointerEvents = null;
437440
}
438441

439442
const placeholderEl = window.document.getElementById(

0 commit comments

Comments
 (0)