diff --git a/src/components/molecules/Select.svelte b/src/components/molecules/Select.svelte index fd6e7c0..be4ed53 100644 --- a/src/components/molecules/Select.svelte +++ b/src/components/molecules/Select.svelte @@ -4,19 +4,27 @@ interface Option { value: string name: string + default?: boolean } export let id: string export let name: string - export let base: Option export let options: Option[] + export let value: string = undefined const dispatch = createEventDispatcher() + const defaultOption = options.find(option => option.default) + const defaultOptionIndex = options.findIndex(option => option.default) - let current: number = 0 + let current: number = defaultOptionIndex let currentOptionEl: HTMLElement $: currentOption = options[current] + // Redefine value from parent (when reset) + $: if (value === defaultOption.value) { + current = defaultOptionIndex + } + /** * When changing select value @@ -37,8 +45,8 @@ ({ value: slug, - name + name, })) ]} - on:change={handleLocationChange} + on:change={handleCountryChange} + value={filterCountry} > Earth @@ -67,14 +96,16 @@
  • @@ -82,12 +113,17 @@
    {#if filtered} - {/if}
    @@ -96,7 +132,7 @@
    - {#each Array(21) as _} + {#each Array(22 * 2) as _}