mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-14 20:40:21 +02:00
16 lines
488 B
TypeScript
16 lines
488 B
TypeScript
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;
|
|
};
|