Auto focus search input when adding component
This commit is contained in:
parent
a9f64abb78
commit
bfd9eff7a6
|
@ -8,6 +8,8 @@
|
||||||
export let id = null
|
export let id = null
|
||||||
export let updateOnChange = true
|
export let updateOnChange = true
|
||||||
export let quiet = false
|
export let quiet = false
|
||||||
|
export let inputRef
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
let focus = false
|
let focus = false
|
||||||
|
|
||||||
|
@ -68,6 +70,7 @@
|
||||||
type="search"
|
type="search"
|
||||||
class="spectrum-Textfield-input spectrum-Search-input"
|
class="spectrum-Textfield-input spectrum-Search-input"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
|
bind:this={inputRef}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
export let updateOnChange = true
|
export let updateOnChange = true
|
||||||
export let quiet = false
|
export let quiet = false
|
||||||
|
export let inputRef
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = e => {
|
const onChange = e => {
|
||||||
|
@ -25,6 +26,7 @@
|
||||||
{value}
|
{value}
|
||||||
{placeholder}
|
{placeholder}
|
||||||
{quiet}
|
{quiet}
|
||||||
|
bind:inputRef
|
||||||
on:change={onChange}
|
on:change={onChange}
|
||||||
on:click
|
on:click
|
||||||
on:input
|
on:input
|
||||||
|
|
|
@ -14,9 +14,11 @@
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
import structure from "./componentStructure.json"
|
import structure from "./componentStructure.json"
|
||||||
import { store } from "builderStore"
|
import { store } from "builderStore"
|
||||||
|
import { onMount } from "svelte"
|
||||||
|
|
||||||
let section = "components"
|
let section = "components"
|
||||||
let searchString
|
let searchString
|
||||||
|
let searchRef
|
||||||
|
|
||||||
$: enrichedStructure = enrichStructure(structure, $store.components)
|
$: enrichedStructure = enrichStructure(structure, $store.components)
|
||||||
$: filteredStructure = filterStructure(
|
$: filteredStructure = filterStructure(
|
||||||
|
@ -52,7 +54,6 @@
|
||||||
if (!structure?.length) {
|
if (!structure?.length) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
if (section === "components") {
|
if (section === "components") {
|
||||||
structure = structure.filter(category => category.name !== "Blocks")
|
structure = structure.filter(category => category.name !== "Blocks")
|
||||||
} else {
|
} else {
|
||||||
|
@ -91,6 +92,10 @@
|
||||||
notifications.error("Error creating component")
|
notifications.error("Error creating component")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
searchRef.focus()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<NavigationPanel
|
<NavigationPanel
|
||||||
|
@ -121,6 +126,7 @@
|
||||||
placeholder="Search"
|
placeholder="Search"
|
||||||
value={searchString}
|
value={searchString}
|
||||||
on:change={e => (searchString = e.detail)}
|
on:change={e => (searchString = e.detail)}
|
||||||
|
bind:inputRef={searchRef}
|
||||||
/>
|
/>
|
||||||
</Layout>
|
</Layout>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
Loading…
Reference in New Issue