Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add props option for smart delete feature #341

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading