We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e305e11 commit 3196a27Copy full SHA for 3196a27
src/js/sidebar.js
@@ -7,5 +7,16 @@ document.addEventListener('click', (e) => {
7
if (toggle) {
8
const layout = toggle.closest('[data-sidebar-layout]');
9
layout?.toggleAttribute('data-sidebar-open');
10
+ return;
11
+ }
12
+
13
+ // Dismiss sidebar when clicking outside (when sidebar is not an overlay).
14
+ if (!e.target.closest('[data-sidebar]')) {
15
+ const layout = document.querySelector('[data-sidebar-layout][data-sidebar-open]');
16
+ // Hardcode breakpoint (for now) as there's no way to use a CSS variable in
17
+ // the @media{} query which could've been picked up here.
18
+ if (layout && window.matchMedia('(max-width: 768px)').matches) {
19
+ layout.removeAttribute('data-sidebar-open');
20
21
}
22
});
0 commit comments