mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
fix(ui-shell): set selectedResultIndex in HeaderSearch on click (#430)
This commit is contained in:
parent
8b7dfbe540
commit
03462e79a7
1 changed files with 6 additions and 2 deletions
|
@ -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}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue