Add prop to deselect rows on outside click

This commit is contained in:
jeffvli 2023-01-06 13:28:10 -08:00
parent 4c275ea878
commit 7b616b44fa
2 changed files with 30 additions and 3 deletions

View file

@ -0,0 +1,15 @@
import { MutableRefObject } from 'react';
import type { AgGridReact as AgGridReactType } from '@ag-grid-community/react/lib/agGridReact';
import { useClickOutside } from '@mantine/hooks';
export const useClickOutsideDeselect = (tableRef: MutableRefObject<AgGridReactType | null>) => {
const handleDeselect = () => {
if (tableRef.current) {
tableRef.current.api.deselectAll();
}
};
const ref = useClickOutside(handleDeselect);
return ref;
};