Skip to content

Commit

Permalink
feat: onReset for "table" and "filters" (#98)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Förg <[email protected]>
  • Loading branch information
fer0n and Michael Förg authored Nov 6, 2023
1 parent f897986 commit 95b45bb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/clearFiltersButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default function ClearFiltersButton<T>() {
state.activeColumns.forEach((column) => {
state.filterValues.delete(column.id);
});
table.getState().props.onReset?.('filters');
});
}}
>
Expand Down
2 changes: 1 addition & 1 deletion src/internalState/useTableState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function useTableState<T>(
props.onHiddenColumnsChange?.(props.defaultHiddenColumns ?? new Set());
}

props.onReset?.();
props.onReset?.('table');
}

const state = useMemo(
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ export interface TableProps<T> extends PartialTableTheme<T> {
};
debug?: (...output: any) => void;
debugRender?: (...output: any) => void;
onReset?: () => void;
onReset?: (scope?: 'table' | 'filters') => void;
}

export type InternalTableProps<T> = MemoizedFunctions<
Expand Down

0 comments on commit 95b45bb

Please sign in to comment.