Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions src/lib/components/app-sidebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,13 @@
<Sidebar.MenuItem>
<Sidebar.MenuButton size="lg" class="!transition-all hover:scale-105 active:scale-95">
{#snippet child({ props })}
<a href="/" {...props}>
<a
href="/"
onclick={() => {
sidebar.setOpenMobile(false);
}}
{...props}
>
<div
class={clsx(
'text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg bg-gray-700 p-1'
Expand All @@ -148,6 +154,7 @@
<button
onclick={function () {
commandOpen = true;
sidebar.setOpenMobile(false);
}}
{...props}
>
Expand Down Expand Up @@ -189,7 +196,13 @@
{...props}
>
{#snippet child({ props })}
<a class=" font-medium" {...props}>
<a
class="font-medium"
onclick={() => {
sidebar.setOpenMobile(false);
}}
{...props}
>
Comment on lines +199 to +205
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Collapsible group trigger now closes the sidebar – breaks submenu usability

Adding sidebar.setOpenMobile(false) here means that tapping “Tools”, “Gmaes”, etc. on a phone collapses the entire sidebar before the submenu can be explored, effectively hiding the submenu.

Unless this is intentional, drop the call or guard it:

-onclick={() => {
-  sidebar.setOpenMobile(false);
-}}
+onclick={() => {
+  if (groupItem.url) {        // only close when real navigation happens
+    sidebar.setOpenMobile(false);
+  }
+}}

This keeps the sidebar open for accordion-style exploration while still closing when the item performs actual navigation.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<a
class="font-medium"
onclick={() => {
sidebar.setOpenMobile(false);
}}
{...props}
>
<a
class="font-medium"
onclick={() => {
if (groupItem.url) {
sidebar.setOpenMobile(false);
}
}}
{...props}
>
🤖 Prompt for AI Agents
In src/lib/components/app-sidebar.svelte around lines 199 to 205, the call to
sidebar.setOpenMobile(false) inside the collapsible group trigger's onclick
handler closes the entire sidebar prematurely, preventing submenu exploration on
mobile. To fix this, remove or conditionally guard the
sidebar.setOpenMobile(false) call so that it only closes the sidebar when an
actual navigation item is clicked, not when expanding submenu groups. This
preserves accordion-style submenu usability while still closing the sidebar on
real navigation actions.

{#if Icon}
<Icon />
{/if}
Expand All @@ -216,6 +229,9 @@
{#snippet child({ props })}
<a
href={item.url}
onclick={() => {
sidebar.setOpenMobile(false);
}}
{...props}
class={clsx(
'group/link z-50 text-nowrap hover:overflow-visible',
Expand Down Expand Up @@ -255,6 +271,9 @@
{...props}
target={groupItem.url.startsWith('http') ? '_blank' : undefined}
rel={groupItem.url.startsWith('http') ? 'noopener noreferrer' : undefined}
onclick={() => {
sidebar.setOpenMobile(false);
}}
>
{#if Icon}
<Icon />
Expand All @@ -274,7 +293,14 @@
<Sidebar.MenuItem>
<Sidebar.MenuButton>
{#snippet child({ props })}
<a target="_blank" href="https://github.com/EducationalTools/src" {...props}>
<a
onclick={() => {
sidebar.setOpenMobile(false);
}}
target="_blank"
href="https://github.com/EducationalTools/src"
{...props}
>
<Code />
EducationalTools/src
</a>
Expand All @@ -285,6 +311,7 @@
<Sidebar.MenuButton
onclick={() => {
settingsOpen.current = true;
sidebar.setOpenMobile(false);
}}
>
<Settings />
Expand Down