diff --git a/packages/nc-gui/components/smartsheet/Grid.vue b/packages/nc-gui/components/smartsheet/Grid.vue index fc8c4f98a3..a03b8b9635 100644 --- a/packages/nc-gui/components/smartsheet/Grid.vue +++ b/packages/nc-gui/components/smartsheet/Grid.vue @@ -942,6 +942,19 @@ const refreshFillHandle = () => { } } +const addRowExpandOnClose = (row: Row) => { + if (!skipRowRemovalOnCancel.value) { + const removed = removeRowIfNew(row) + + if (removed) { + clearSelectedRange() + + activeCell.row = null + activeCell.col = null + } + } +} + watch( [() => selectedRange.end.row, () => selectedRange.end.col, () => activeCell.row, () => activeCell.col], ([sr, sc, ar, ac], [osr, osc, oar, oac]) => { @@ -1311,7 +1324,7 @@ useEventListener(document, 'mouseup', () => { :state="expandedFormRowState" :meta="meta" :view="view" - @update:model-value="!skipRowRemovalOnCancel && removeRowIfNew(expandedFormRow)" + @update:model-value="addRowExpandOnClose(expandedFormRow)" /> diff --git a/packages/nc-gui/composables/useViewData.ts b/packages/nc-gui/composables/useViewData.ts index 4a996fd75e..a95e0e25bf 100644 --- a/packages/nc-gui/composables/useViewData.ts +++ b/packages/nc-gui/composables/useViewData.ts @@ -938,7 +938,9 @@ export function useViewData( if (index > -1 && row.rowMeta.new) { formattedData.value.splice(index, 1) + return true } + return false } // get current expanded row index