Fix current product detection on Shop location switcher select

This commit is contained in:
2022-06-21 13:38:55 +02:00
parent deb0c1d708
commit 23b0035272
2 changed files with 3 additions and 3 deletions

View File

@@ -1,9 +1,9 @@
<script lang="ts"> <script lang="ts">
import { page } from '$app/stores'
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import { getContext } from 'svelte' import { getContext } from 'svelte'
export let isOver: boolean = false export let isOver: boolean = false
export let currentProductSlug: string = undefined
const { shopLocations } = getContext('shop') const { shopLocations } = getContext('shop')
@@ -29,7 +29,7 @@
</svg> </svg>
<select on:change={quickLocationChange}> <select on:change={quickLocationChange}>
{#each shopLocations as { name, slug }} {#each shopLocations as { name, slug }}
<option value={slug} selected={slug === $page.params.name}>{name}</option> <option value={slug} selected={slug === currentProductSlug}>{name}</option>
{/each} {/each}
</select> </select>
</dd> </dd>

View File

@@ -128,6 +128,6 @@
class:is-visible={scrolledPastIntro} class:is-visible={scrolledPastIntro}
class:is-overlaid={$cartOpen} class:is-overlaid={$cartOpen}
> >
<ShopLocationSwitcher /> <ShopLocationSwitcher currentProductSlug={product && product.location.slug} />
<ButtonCart /> <ButtonCart />
</nav> </nav>