fix(ui-shell): set selectedResultIndex in HeaderSearch on click (#430)

This commit is contained in:
Eric Liu 2020-11-28 06:17:33 -08:00 committed by GitHub
commit 03462e79a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -26,7 +26,7 @@
/** Specify the selected result index */
export let selectedResultIndex = 0;
import { createEventDispatcher } from "svelte";
import { createEventDispatcher, tick } from "svelte";
import Close20 from "carbon-icons-svelte/lib/Close20/Close20.svelte";
import Search20 from "carbon-icons-svelte/lib/Search20/Search20.svelte";
@ -270,7 +270,11 @@
role="menuitem"
href="{result.href}"
class:selected="{selectedId === `search-menuitem-${i}`}"
on:click|preventDefault="{selectResult}"
on:click|preventDefault="{async () => {
selectedResultIndex = i;
await tick();
selectResult();
}}"
>
<slot result="{result}" index="{i}">
{result.text}