From 0f49b732e956ba75e69dd81417457a94afe7f3c7 Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Sat, 7 Dec 2024 07:37:04 +0000 Subject: [PATCH] fix(nc-gui): allow user to clear form view field lable input and start from begining #4130 --- .../nc-gui/components/smartsheet/Form.vue | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/nc-gui/components/smartsheet/Form.vue b/packages/nc-gui/components/smartsheet/Form.vue index 36ab5528f9..f667e52911 100644 --- a/packages/nc-gui/components/smartsheet/Form.vue +++ b/packages/nc-gui/components/smartsheet/Form.vue @@ -655,10 +655,30 @@ const handleOnUploadImage = (data: AttachmentResType = null) => { updateView() } +const isFocusedFieldLabel = ref(false) + const onFocusActiveFieldLabel = (e: FocusEvent) => { + isFocusedFieldLabel.value = true + + if (activeField.value && !activeField.value.label) { + activeField.value.label = activeField.value?.title ?? '' + } + ;(e.target as HTMLTextAreaElement).select() } +const activeFieldLabel = computed(() => { + if (!isFocusedFieldLabel.value && !activeField.value?.label) { + return activeField.value?.title + } + + return activeField.value?.label ?? '' +}) + +onClickOutside(focusLabel, () => { + isFocusedFieldLabel.value = false +}) + const updateFieldTitle = (value: string) => { if (!activeField.value) return @@ -1459,7 +1479,7 @@ useEventListener(