diff --git a/src/components/DataSheetGrid.tsx b/src/components/DataSheetGrid.tsx index 5c5bdd6..60cacaa 100644 --- a/src/components/DataSheetGrid.tsx +++ b/src/components/DataSheetGrid.tsx @@ -77,6 +77,7 @@ export const DataSheetGrid = React.memo( autoAddRow = false, lockRows = false, disableExpandSelection = false, + disableSmartDelete = false, duplicateRow = DEFAULT_DUPLICATE_ROW, contextMenuComponent: ContextMenuComponent = ContextMenu, disableContextMenu: disableContextMenuRaw = false, @@ -513,7 +514,8 @@ export const DataSheetGrid = React.memo( ) const deleteSelection = useCallback( - (smartDelete = true) => { + (_smartDelete = true) => { + const smartDelete = _smartDelete && !disableSmartDelete if (!activeCell) { return } diff --git a/src/types.ts b/src/types.ts index 768ec55..7e5adb9 100644 --- a/src/types.ts +++ b/src/types.ts @@ -148,6 +148,7 @@ export type DataSheetGridProps = { lockRows?: boolean disableContextMenu?: boolean disableExpandSelection?: boolean + disableSmartDelete?: boolean contextMenuComponent?: ( props: ContextMenuComponentProps ) => React.ReactElement | null diff --git a/website/docs/api-reference/props.mdx b/website/docs/api-reference/props.mdx index c11b9fd..40267dd 100644 --- a/website/docs/api-reference/props.mdx +++ b/website/docs/api-reference/props.mdx @@ -178,6 +178,12 @@ When true, no context menu is shown when right clicking. `disableContextMenu` is When true, the user will not be able to drag the corner of the selection to expand it. +### disableSmartDelete +> Type: `boolean`
+> Default: `false` + +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. + ## Style ### className > Type: `string`