fix: close sidebar when tapping outside on mobile

Add a semi-transparent backdrop overlay (lg:hidden) behind the sidebar
on mobile. Clicking/tapping the backdrop closes the sidebar.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Frederic Cabassut
2026-03-06 23:12:36 +01:00
co-authored by Claude Opus 4.6
parent cce29705a2
commit f652f97e0f
2 changed files with 12 additions and 2 deletions
+11 -1
View File
@@ -5,9 +5,10 @@
interface Props {
open: boolean;
onClose?: () => void;
}
let { open }: Props = $props();
let { open, onClose }: Props = $props();
function setFilter(filter: NoteFilter) {
selectedTag.set(null);
@@ -20,6 +21,15 @@
}
</script>
{#if open}
<!-- svelte-ignore a11y_no_static_element_interactions -->
<div
class="fixed inset-0 top-16 z-10 bg-black/30 lg:hidden"
onclick={onClose}
onkeydown={(e) => { if (e.key === 'Escape') onClose?.(); }}
></div>
{/if}
<aside
class="fixed left-0 top-16 z-20 h-[calc(100vh-4rem)] w-64 transform border-r border-[var(--border)] bg-[var(--bg-surface)] transition-transform duration-200 {open ? 'translate-x-0' : '-translate-x-full'}"
>