Fix bulk deletion triggering on delete keypress after selecting then deselecting a row
This commit is contained in:
parent
0a0e78c314
commit
834202423f
|
@ -21,16 +21,7 @@
|
|||
svelteDispatch("select")
|
||||
const id = row?._id
|
||||
if (id) {
|
||||
selectedRows.update(state => {
|
||||
let newState = {
|
||||
...state,
|
||||
[id]: !state[id],
|
||||
}
|
||||
if (!newState[id]) {
|
||||
delete newState[id]
|
||||
}
|
||||
return newState
|
||||
})
|
||||
selectedRows.actions.toggleRow(id)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -224,10 +224,7 @@
|
|||
if (!id || id === NewRowID) {
|
||||
return
|
||||
}
|
||||
selectedRows.update(state => {
|
||||
state[id] = !state[id]
|
||||
return state
|
||||
})
|
||||
selectedRows.actions.toggleRow(id)
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
|
|
|
@ -25,14 +25,33 @@ export const createStores = () => {
|
|||
null
|
||||
)
|
||||
|
||||
// Toggles whether a certain row ID is selected or not
|
||||
const toggleSelectedRow = id => {
|
||||
selectedRows.update(state => {
|
||||
let newState = {
|
||||
...state,
|
||||
[id]: !state[id],
|
||||
}
|
||||
if (!newState[id]) {
|
||||
delete newState[id]
|
||||
}
|
||||
return newState
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
focusedCellId,
|
||||
focusedCellAPI,
|
||||
focusedRowId,
|
||||
previousFocusedRowId,
|
||||
selectedRows,
|
||||
hoveredRowId,
|
||||
rowHeight,
|
||||
selectedRows: {
|
||||
...selectedRows,
|
||||
actions: {
|
||||
toggleRow: toggleSelectedRow,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue