Skip to content

Commit c03253d

Browse files
author
Deniz97
committed
chore: add props option for smart delete feature
1 parent 0ab04b7 commit c03253d

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/components/DataSheetGrid.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export const DataSheetGrid = React.memo(
7777
autoAddRow = false,
7878
lockRows = false,
7979
disableExpandSelection = false,
80+
disableSmartDelete = false,
8081
duplicateRow = DEFAULT_DUPLICATE_ROW,
8182
contextMenuComponent: ContextMenuComponent = ContextMenu,
8283
disableContextMenu: disableContextMenuRaw = false,
@@ -513,7 +514,8 @@ export const DataSheetGrid = React.memo(
513514
)
514515

515516
const deleteSelection = useCallback(
516-
(smartDelete = true) => {
517+
(_smartDelete = true) => {
518+
const smartDelete = _smartDelete && !disableSmartDelete
517519
if (!activeCell) {
518520
return
519521
}

src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ export type DataSheetGridProps<T> = {
148148
lockRows?: boolean
149149
disableContextMenu?: boolean
150150
disableExpandSelection?: boolean
151+
disableSmartDelete?: boolean
151152
contextMenuComponent?: (
152153
props: ContextMenuComponentProps
153154
) => React.ReactElement | null

website/docs/api-reference/props.mdx

+6
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ When true, no context menu is shown when right clicking. `disableContextMenu` is
178178

179179
When true, the user will not be able to drag the corner of the selection to expand it.
180180

181+
### disableSmartDelete
182+
> Type: `boolean`<br />
183+
> Default: `false`
184+
185+
When false, deleting an empty cell will select the whole row, and deleting an empty cell of an empty row will actually remove the row from the sheet. Second behaviour is auto-disabled if the lockRows option is enabled.
186+
181187
## Style
182188
### className
183189
> Type: `string`

0 commit comments

Comments
 (0)