Skip to content

Commit

Permalink
chore: add props option for smart delete feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Deniz97 committed Mar 22, 2024
1 parent 0ab04b7 commit c03253d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/DataSheetGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -513,7 +514,8 @@ export const DataSheetGrid = React.memo(
)

const deleteSelection = useCallback(
(smartDelete = true) => {
(_smartDelete = true) => {
const smartDelete = _smartDelete && !disableSmartDelete
if (!activeCell) {
return
}
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export type DataSheetGridProps<T> = {
lockRows?: boolean
disableContextMenu?: boolean
disableExpandSelection?: boolean
disableSmartDelete?: boolean
contextMenuComponent?: (
props: ContextMenuComponentProps
) => React.ReactElement | null
Expand Down
6 changes: 6 additions & 0 deletions website/docs/api-reference/props.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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`<br />
> 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`
Expand Down

0 comments on commit c03253d

Please sign in to comment.