Skip to content

Commit

Permalink
Merge branch 'master' of github.com:IBM/carbon-components-svelte
Browse files Browse the repository at this point in the history
  • Loading branch information
ispyinternet committed Nov 30, 2020
2 parents 36987b2 + e9016a5 commit 626fd99
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- ## Unreleased -->

## [0.25.1](https://github.com/IBM/carbon-components-svelte/releases/tag/v0.25.1) - 2020-11-28

**Fixes**

- set `selectedResultIndex` in HeaderSearch when clicking a result ([PR #430](https://github.com/IBM/carbon-components-svelte/pull/430), [issue #429](https://github.com/IBM/carbon-components-svelte/issues/429))

## [0.25.0](https://github.com/IBM/carbon-components-svelte/releases/tag/v0.25.0) - 2020-11-27

**Features**
Expand Down
2 changes: 1 addition & 1 deletion COMPONENT_INDEX.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Component Index

> 155 components exported from [email protected].0.
> 155 components exported from [email protected].1.
## Components

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "carbon-components-svelte",
"version": "0.25.0",
"version": "0.25.1",
"license": "Apache-2.0",
"author": "IBM",
"description": "Svelte implementation of the Carbon Design System",
Expand Down
14 changes: 10 additions & 4 deletions src/UIShell/HeaderSearch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -223,19 +223,21 @@
on:focus
on:blur
on:keydown
on:keydown="{({ key }) => {
switch (key) {
on:keydown="{(e) => {
switch (e.key) {
case 'Enter':
selectResult();
break;
case 'ArrowDown':
e.preventDefault();
if (selectedResultIndex === results.length - 1) {
selectedResultIndex = 0;
} else {
selectedResultIndex += 1;
}
break;
case 'ArrowUp':
e.preventDefault();
if (selectedResultIndex === 0) {
selectedResultIndex = results.length - 1;
} else {
Expand Down Expand Up @@ -270,7 +272,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}
Expand Down

0 comments on commit 626fd99

Please sign in to comment.