Browse Source

fix: clear selection if row deleted is included

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/5896/head
mertmit 1 year ago
parent
commit
8a2a3846e4
  1. 9
      packages/nc-gui/components/smartsheet/Grid.vue
  2. 18
      packages/nc-gui/composables/useMultiSelect/cellRange.ts
  3. 20
      packages/nc-gui/composables/useMultiSelect/index.ts

9
packages/nc-gui/components/smartsheet/Grid.vue

@ -879,6 +879,15 @@ const closeAddColumnDropdown = (scrollToLastCol = false) => {
const confirmDeleteRow = (row: number) => {
try {
deleteRow(row)
if (selectedRange.isRowInRange(row)) {
clearSelectedRange()
}
if (activeCell.row === row) {
activeCell.row = null
activeCell.col = null
}
} catch (e: any) {
message.error(e.message)
}

18
packages/nc-gui/composables/useMultiSelect/cellRange.ts

@ -24,6 +24,24 @@ export class CellRange {
return !this.isEmpty() && this._start?.row === this._end?.row
}
isCellInRange(cell: Cell) {
return (
!this.isEmpty() &&
cell.row >= this.start.row &&
cell.row <= this.end.row &&
cell.col >= this.start.col &&
cell.col <= this.end.col
)
}
isRowInRange(row: number) {
return !this.isEmpty() && row >= this.start.row && row <= this.end.row
}
isColInRange(col: number) {
return !this.isEmpty() && col >= this.start.col && col <= this.end.col
}
get start(): Cell {
return {
row: Math.min(this._start?.row ?? NaN, this._end?.row ?? NaN),

20
packages/nc-gui/composables/useMultiSelect/index.ts

@ -232,16 +232,7 @@ export function useMultiSelect(
return true
}
if (selectedRange._start === null || selectedRange._end === null) {
return false
}
return (
col >= selectedRange.start.col &&
col <= selectedRange.end.col &&
row >= selectedRange.start.row &&
row <= selectedRange.end.row
)
return selectedRange.isCellInRange({ row, col })
}
function isCellInFillRange(row: number, col: number) {
@ -249,16 +240,11 @@ export function useMultiSelect(
return false
}
if (
col >= selectedRange.start.col &&
col <= selectedRange.end.col &&
row >= selectedRange.start.row &&
row <= selectedRange.end.row
) {
if (selectedRange.isCellInRange({ row, col })) {
return false
}
return col >= fillRange.start.col && col <= fillRange.end.col && row >= fillRange.start.row && row <= fillRange.end.row
return fillRange.isCellInRange({ row, col })
}
const isPasteable = (row?: Row, col?: ColumnType, showInfo = false) => {

Loading…
Cancel
Save