Handle enters
This commit is contained in:
parent
24bef1ee9d
commit
64ab8ecf18
|
@ -1,6 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { tick } from "svelte"
|
import { tick } from "svelte"
|
||||||
import { Icon, Body } from "@budibase/bbui"
|
import { Icon, Body } from "@budibase/bbui"
|
||||||
|
import { keyUtils } from "helpers/keyUtils"
|
||||||
|
|
||||||
export let title
|
export let title
|
||||||
export let placeholder
|
export let placeholder
|
||||||
|
@ -50,11 +51,21 @@
|
||||||
<div class="title" class:hide={search}>
|
<div class="title" class:hide={search}>
|
||||||
<Body size="S">{title}</Body>
|
<Body size="S">{title}</Body>
|
||||||
</div>
|
</div>
|
||||||
<div on:click={openSearch} class="searchButton" class:hide={search}>
|
<div
|
||||||
|
on:click={openSearch}
|
||||||
|
on:keydown={keyUtils.handleEnter(openSearch)}
|
||||||
|
class="searchButton"
|
||||||
|
class:hide={search}
|
||||||
|
>
|
||||||
<Icon size="S" name="Search" />
|
<Icon size="S" name="Search" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div on:click={handleAddButton} class="addButton" class:rotate={search}>
|
<div
|
||||||
|
on:click={handleAddButton}
|
||||||
|
on:keydown={keyUtils.handleEnter(handleAddButton)}
|
||||||
|
class="addButton"
|
||||||
|
class:rotate={search}
|
||||||
|
>
|
||||||
<Icon name="Add" />
|
<Icon name="Add" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
function handleEnter(fnc) {
|
||||||
|
return e => e.key === "Enter" && fnc()
|
||||||
|
}
|
||||||
|
|
||||||
|
export const keyUtils = {
|
||||||
|
handleEnter,
|
||||||
|
}
|
Loading…
Reference in New Issue