focus input when popover opens

This commit is contained in:
Peter Clement 2023-08-11 11:59:40 +01:00
parent a444d6a732
commit f7c1db5926
1 changed files with 13 additions and 3 deletions

View File

@ -12,7 +12,7 @@
OptionSelectDnD, OptionSelectDnD,
Layout, Layout,
} from "@budibase/bbui" } from "@budibase/bbui"
import { createEventDispatcher, getContext } from "svelte" import { createEventDispatcher, getContext, onMount } from "svelte"
import { cloneDeep } from "lodash/fp" import { cloneDeep } from "lodash/fp"
import { tables, datasources } from "stores/backend" import { tables, datasources } from "stores/backend"
import { TableNames, UNEDITABLE_USER_FIELDS } from "constants" import { TableNames, UNEDITABLE_USER_FIELDS } from "constants"
@ -47,6 +47,7 @@
export let field export let field
let mounted = false
let fieldDefinitions = cloneDeep(FIELDS) let fieldDefinitions = cloneDeep(FIELDS)
let originalName let originalName
let linkEditDisabled let linkEditDisabled
@ -95,6 +96,7 @@
} else { } else {
editableColumn.name = "Column 01" editableColumn.name = "Column 01"
} }
focus = true
} }
allowedTypes = getAllowedTypes() allowedTypes = getAllowedTypes()
} }
@ -413,16 +415,24 @@
} }
return newError return newError
} }
onMount(() => {
mounted = true
})
$: console.log(editableColumn.name)
</script> </script>
<Layout noPadding gap="S"> <Layout noPadding gap="S">
<Input {#if mounted}
<Input
autofocus
bind:value={editableColumn.name} bind:value={editableColumn.name}
disabled={uneditable || disabled={uneditable ||
(linkEditDisabled && editableColumn.type === LINK_TYPE)} (linkEditDisabled && editableColumn.type === LINK_TYPE)}
error={errors?.name} error={errors?.name}
/> />
{/if}
<Select <Select
disabled={!typeEnabled} disabled={!typeEnabled}
bind:value={editableColumn.type} bind:value={editableColumn.type}