Browse Source

refactor(gui-v2): use onSetRef

pull/2959/head
Wing-Kam Wong 2 years ago
parent
commit
37e45ac53a
  1. 15
      packages/nc-gui-v2/components/cell/Text.vue

15
packages/nc-gui-v2/components/cell/Text.vue

@ -15,20 +15,13 @@ const root = ref<HTMLInputElement>()
const vModel = useVModel(props, 'modelValue', emits) const vModel = useVModel(props, 'modelValue', emits)
onMounted(() => { const onSetRef = (el: HTMLInputElement) => {
root.value?.focus() el.focus()
}) }
watch(
() => root.value,
(el) => {
el?.focus()
},
)
</script> </script>
<template> <template>
<input v-if="editEnabled" ref="root" v-model="vModel" class="h-full w-full outline-none" /> <input v-if="editEnabled" :ref="onSetRef" v-model="vModel" class="h-full w-full outline-none" />
<span v-else>{{ vModel }}</span> <span v-else>{{ vModel }}</span>
</template> </template>

Loading…
Cancel
Save