1
0
Fork 0
mirror of synced 2024-09-15 08:47:37 +12:00

Auto focus search input when adding component

This commit is contained in:
Andrew Kingston 2022-05-10 18:48:43 +01:00
parent c7f4978d05
commit 68b20b69d4
3 changed files with 12 additions and 1 deletions

View file

@ -8,6 +8,8 @@
export let id = null
export let updateOnChange = true
export let quiet = false
export let inputRef
const dispatch = createEventDispatcher()
let focus = false
@ -68,6 +70,7 @@
type="search"
class="spectrum-Textfield-input spectrum-Search-input"
autocomplete="off"
bind:this={inputRef}
/>
</div>
<button

View file

@ -10,6 +10,7 @@
export let disabled = false
export let updateOnChange = true
export let quiet = false
export let inputRef
const dispatch = createEventDispatcher()
const onChange = e => {
@ -25,6 +26,7 @@
{value}
{placeholder}
{quiet}
bind:inputRef
on:change={onChange}
on:click
on:input

View file

@ -14,9 +14,11 @@
} from "@budibase/bbui"
import structure from "./componentStructure.json"
import { store } from "builderStore"
import { onMount } from "svelte"
let section = "components"
let searchString
let searchRef
$: enrichedStructure = enrichStructure(structure, $store.components)
$: filteredStructure = filterStructure(
@ -52,7 +54,6 @@
if (!structure?.length) {
return []
}
if (section === "components") {
structure = structure.filter(category => category.name !== "Blocks")
} else {
@ -91,6 +92,10 @@
notifications.error("Error creating component")
}
}
onMount(() => {
searchRef.focus()
})
</script>
<NavigationPanel
@ -121,6 +126,7 @@
placeholder="Search"
value={searchString}
on:change={e => (searchString = e.detail)}
bind:inputRef={searchRef}
/>
</Layout>
{/if}