Browse Source

feat(gui-v2): focus new added option on select options

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/3022/head
mertmit 2 years ago
parent
commit
dc16eaee2b
  1. 14
      packages/nc-gui-v2/components/smartsheet-column/SelectOptions.vue

14
packages/nc-gui-v2/components/smartsheet-column/SelectOptions.vue

@ -8,16 +8,17 @@ import MdiArrowDownDropCircle from '~icons/mdi/arrow-down-drop-circle'
import MdiClose from '~icons/mdi/close' import MdiClose from '~icons/mdi/close'
import MdiPlusIcon from '~icons/mdi/plus' import MdiPlusIcon from '~icons/mdi/plus'
const { formState, validateInfos, setAdditionalValidations, sqlUi, onDataTypeChange, onAlter } = useColumnCreateStoreOrThrow() const { formState, setAdditionalValidations } = useColumnCreateStoreOrThrow()
let options = $ref<any[]>([]) let options = $ref<any[]>([])
const colorMenus = $ref<any>({}) const colorMenus = $ref<any>({})
const colors = $ref(enumColor.light) const colors = $ref(enumColor.light)
const inputs = ref()
const validators = { const validators = {
'colOptions.options': [ 'colOptions.options': [
{ {
validator: (_: any, opt: any) => { validator: (_: any, _opt: any) => {
return new Promise<void>((resolve, reject) => { return new Promise<void>((resolve, reject) => {
for (const opt of options) { for (const opt of options) {
if (!opt.title.length) { if (!opt.title.length) {
@ -74,6 +75,13 @@ onMounted(() => {
op.title = op.title.replace(/^'/, '').replace(/'$/, '') op.title = op.title.replace(/^'/, '').replace(/'$/, '')
} }
}) })
// focus last created input
watch(inputs, () => {
if (inputs.value?.$el) {
inputs.value.$el.focus()
}
})
</script> </script>
<template> <template>
@ -88,7 +96,7 @@ onMounted(() => {
</template> </template>
<MdiArrowDownDropCircle :style="{ 'font-size': '1.5em', 'color': element.color }" class="mr-2" /> <MdiArrowDownDropCircle :style="{ 'font-size': '1.5em', 'color': element.color }" class="mr-2" />
</a-dropdown> </a-dropdown>
<a-input v-model:value="element.title" class="caption" /> <a-input ref="inputs" v-model:value="element.title" class="caption" />
<MdiClose class="ml-2" :style="{ color: 'red' }" @click="removeOption(index)" /> <MdiClose class="ml-2" :style="{ color: 'red' }" @click="removeOption(index)" />
</div> </div>
</template> </template>

Loading…
Cancel
Save