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) => {