SvelteKit: fix issue where clicking link with no href refreshed the page (#64136)

<!-- PR description tips:
https://www.notion.so/sourcegraph/Write-a-good-pull-request-description-610a7fd3e613496eb76f450db5a49b6e
-->
When clicking a menu item with no href, page refreshed every time. Now,
menu items with no href cause no action when clicked.


https://github.com/user-attachments/assets/abcc5164-64fa-4b37-8f8c-7df110bca23e

This is a follow up to this PR:
https://github.com/sourcegraph/sourcegraph/pull/64134

## Test plan
Manual/Visual testing
<!-- REQUIRED; info at
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles
-->

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
This commit is contained in:
Jason Hawk Harris 2024-07-29 14:57:49 -05:00 committed by GitHub
parent 288a7b6b83
commit e0fa2bd66e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -85,13 +85,16 @@
<li class:open on:mouseenter={() => openMenu(entry.label)} on:mouseleave={closeMenu}>
{#if isNavigationMenu(entry)}
<span>
<MainNavigationLink {entry} />
<Button
variant="icon"
on:click={() => (openedMenu = open ? '' : entry.label)}
aria-label="{open ? 'Close' : 'Open'} '{entry.label}' submenu"
aria-expanded={open}
>
{#if entry.icon}
<Icon icon={entry.icon} aria-hidden="true" inline />&nbsp;
{/if}
{entry.label}
<Icon icon={ILucideChevronDown} inline aria-hidden />
</Button>
</span>