From eb9f6930fd5774670401a689dda1561657464929 Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Thu, 22 Feb 2024 16:16:35 +0000 Subject: [PATCH] fix(nc-gui): form field reorder issue --- .../nc-gui/components/smartsheet/Form.vue | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/Form.vue b/packages/nc-gui/components/smartsheet/Form.vue index 66215d003a..48b2450d97 100644 --- a/packages/nc-gui/components/smartsheet/Form.vue +++ b/packages/nc-gui/components/smartsheet/Form.vue @@ -194,13 +194,20 @@ function onMoveCallback(event: any) { // Todo: reorder visible form fields function onMove(event: any, isVisibleFormFields = false) { - const { newIndex, element, oldIndex } = event.moved + let { newIndex, element, oldIndex } = event.moved const fieldIndex = fields.value?.findIndex((f) => f?.fk_column_id === element.fk_column_id) if (fieldIndex === -1 || fieldIndex === undefined) return - const localColumnIndex = localColumns.value?.findIndex((c) => c.fk_column_id === element.fk_column_id) + if (isVisibleFormFields) { + element = localColumns.value[localColumns.value?.findIndex((c) => c.fk_column_id === element.fk_column_id)] + newIndex = localColumns.value.findIndex( + (c) => + c.fk_column_id === + visibleColumns.value[newIndex > oldIndex ? newIndex - 1 : newIndex < oldIndex ? newIndex + 1 : newIndex].fk_column_id, + ) + } if (!localColumns.value.length || localColumns.value.length === 1) { element.order = 1 @@ -483,7 +490,7 @@ const onFormItemClick = (element: any) => {