Browse Source

fix(nc-gui): form view onclick focus issue

pull/7664/head
Ramesh Mane 10 months ago
parent
commit
06e14f5054
  1. 32
      packages/nc-gui/components/smartsheet/Form.vue

32
packages/nc-gui/components/smartsheet/Form.vue

@ -24,6 +24,7 @@ import {
reactive, reactive,
ref, ref,
useDebounceFn, useDebounceFn,
useEventListener,
useGlobal, useGlobal,
useI18n, useI18n,
useNuxtApp, useNuxtApp,
@ -31,7 +32,6 @@ import {
useViewColumnsOrThrow, useViewColumnsOrThrow,
useViewData, useViewData,
watch, watch,
useEventListener,
} from '#imports' } from '#imports'
provide(IsFormInj, ref(true)) provide(IsFormInj, ref(true))
@ -115,6 +115,8 @@ const submitted = ref(false)
const activeRow = ref('') const activeRow = ref('')
const isLoadingFormView = ref(false)
const focusLabel: VNodeRef = (el) => { const focusLabel: VNodeRef = (el) => {
return (el as HTMLInputElement)?.focus() return (el as HTMLInputElement)?.focus()
} }
@ -396,8 +398,10 @@ onClickOutside(draggableRef, () => {
}) })
onMounted(async () => { onMounted(async () => {
isLoadingFormView.value = true
await loadFormView() await loadFormView()
setFormData() setFormData()
isLoadingFormView.value = false
}) })
watch(view, (nextView) => { watch(view, (nextView) => {
@ -416,11 +420,8 @@ useEventListener(document, 'focusout', (e: FocusEvent) => {
const nextActiveFieldTitle = const nextActiveFieldTitle =
e?.relatedTarget?.getAttribute('data-title') || e?.relatedTarget?.getAttribute('data-title') ||
e?.relatedTarget?.offsetParent?.closest('.nc-form-focus-element')?.getAttribute('data-title') e?.relatedTarget?.offsetParent?.closest('.nc-form-focus-element')?.getAttribute('data-title')
if (nextActiveFieldTitle && activeRow.value !== nextActiveFieldTitle) {
if (activeRow.value && nextActiveFieldTitle && activeRow.value !== nextActiveFieldTitle) {
activeRow.value = nextActiveFieldTitle activeRow.value = nextActiveFieldTitle
} else {
console.log(document.activeElement)
} }
}) })
</script> </script>
@ -494,8 +495,9 @@ useEventListener(document, 'focusout', (e: FocusEvent) => {
</div> </div>
<div v-else class="h-full w-full flex" data-testid="nc-form-wrapper"> <div v-else class="h-full w-full flex" data-testid="nc-form-wrapper">
<div v-if="isLoadingFormView" class="flex-1"></div>
<div <div
v-if="formViewData" v-else-if="formViewData"
class="flex-1 h-full overflow-auto nc-form-scrollbar p-6" class="flex-1 h-full overflow-auto nc-form-scrollbar p-6"
:style="{background:(formViewData?.meta as Record<string,any>).theme_color || '#F9F9FA'}" :style="{background:(formViewData?.meta as Record<string,any>).theme_color || '#F9F9FA'}"
> >
@ -598,7 +600,7 @@ useEventListener(document, 'focusout', (e: FocusEvent) => {
@start="drag = true" @start="drag = true"
@end="drag = false" @end="drag = false"
> >
<template #item="{ element, index }"> <template #item="{ element }">
<div <div
class="nc-editable nc-form-focus-element item relative bg-white" class="nc-editable nc-form-focus-element item relative bg-white"
:class="[ :class="[
@ -673,9 +675,9 @@ useEventListener(document, 'focusout', (e: FocusEvent) => {
</span> </span>
<a-switch <a-switch
v-model:checked="element.required" v-model:checked="element.required"
v-e="['a:form-view:field:mark-required']"
class="nc-form-input-required" class="nc-form-input-required"
data-testid="nc-form-input-required" data-testid="nc-form-input-required"
v-e="['a:form-view:field:mark-required']"
size="small" size="small"
@change="updateColMeta(element)" @change="updateColMeta(element)"
/> />
@ -751,7 +753,17 @@ useEventListener(document, 'focusout', (e: FocusEvent) => {
}, },
]" ]"
> >
<LazySmartsheetDivDataCell class="relative" @click.stop> <LazySmartsheetDivDataCell
class="relative"
@click.capture="
(e) => {
if (activeRow !== element.title) {
onFormItemClick(element)
e.stopPropagation()
}
}
"
>
<LazySmartsheetVirtualCell <LazySmartsheetVirtualCell
v-if="isVirtualCol(element)" v-if="isVirtualCol(element)"
v-model="formState[element.title]" v-model="formState[element.title]"
@ -841,7 +853,7 @@ useEventListener(document, 'focusout', (e: FocusEvent) => {
</a-card> </a-card>
</div> </div>
</div> </div>
<div v-if="isEditable" class="h-full w-full max-w-[384px] nc-form-left-drawer border-l border-gray-200"> <div v-if="isEditable" class="h-full flex-1 max-w-[384px] nc-form-left-drawer border-l border-gray-200">
<Splitpanes horizontal class="w-full nc-form-right-splitpane"> <Splitpanes horizontal class="w-full nc-form-right-splitpane">
<Pane min-size="30" size="50" class="nc-form-right-splitpane-item p-4 flex flex-col space-y-4 !min-h-200px"> <Pane min-size="30" size="50" class="nc-form-right-splitpane-item p-4 flex flex-col space-y-4 !min-h-200px">
<div class="flex flex-wrap justify-between items-center gap-2"> <div class="flex flex-wrap justify-between items-center gap-2">

Loading…
Cancel
Save