Browse Source

fix: clear selection if add row cancelled

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/6004/head
mertmit 1 year ago
parent
commit
c2906b6222
  1. 15
      packages/nc-gui/components/smartsheet/Grid.vue
  2. 2
      packages/nc-gui/composables/useViewData.ts

15
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( watch(
[() => selectedRange.end.row, () => selectedRange.end.col, () => activeCell.row, () => activeCell.col], [() => selectedRange.end.row, () => selectedRange.end.col, () => activeCell.row, () => activeCell.col],
([sr, sc, ar, ac], [osr, osc, oar, oac]) => { ([sr, sc, ar, ac], [osr, osc, oar, oac]) => {
@ -1311,7 +1324,7 @@ useEventListener(document, 'mouseup', () => {
:state="expandedFormRowState" :state="expandedFormRowState"
:meta="meta" :meta="meta"
:view="view" :view="view"
@update:model-value="!skipRowRemovalOnCancel && removeRowIfNew(expandedFormRow)" @update:model-value="addRowExpandOnClose(expandedFormRow)"
/> />
</Suspense> </Suspense>

2
packages/nc-gui/composables/useViewData.ts

@ -938,7 +938,9 @@ export function useViewData(
if (index > -1 && row.rowMeta.new) { if (index > -1 && row.rowMeta.new) {
formattedData.value.splice(index, 1) formattedData.value.splice(index, 1)
return true
} }
return false
} }
// get current expanded row index // get current expanded row index

Loading…
Cancel
Save