Browse Source

refactor(gui-v2): use onSetRef

pull/2960/head
Wing-Kam Wong 2 years ago
parent
commit
fa11ac70c4
  1. 19
      packages/nc-gui-v2/components/cell/TextArea.vue

19
packages/nc-gui-v2/components/cell/TextArea.vue

@ -11,26 +11,17 @@ const emits = defineEmits(['update:modelValue'])
const editEnabled = inject<boolean>('editEnabled', false) const editEnabled = inject<boolean>('editEnabled', false)
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>
<textarea <textarea
v-if="editEnabled" v-if="editEnabled"
ref="root" :ref="onSetRef"
v-model="vModel" v-model="vModel"
rows="4" rows="4"
class="h-full w-full min-h-[60px] outline-none" class="h-full w-full min-h-[60px] outline-none"
@ -44,4 +35,4 @@ watch(
textarea:focus { textarea:focus {
@apply ring-transparent; @apply ring-transparent;
} }
</style> </style>
Loading…
Cancel
Save