diff --git a/packages/grafana-ui/src/components/Table/CellActions.tsx b/packages/grafana-ui/src/components/Table/CellActions.tsx index d0b368bdf55..568d2f1ca5a 100644 --- a/packages/grafana-ui/src/components/Table/CellActions.tsx +++ b/packages/grafana-ui/src/components/Table/CellActions.tsx @@ -25,13 +25,19 @@ export function CellActions({ field, cell, previewMode, onCellFilterAdded }: Cel }; const onFilterFor = useCallback( - (event: React.MouseEvent) => - onCellFilterAdded({ key: field.name, operator: FILTER_FOR_OPERATOR, value: cell.value }), + (event: React.MouseEvent) => { + if (onCellFilterAdded) { + onCellFilterAdded({ key: field.name, operator: FILTER_FOR_OPERATOR, value: cell.value }); + } + }, [cell, field, onCellFilterAdded] ); const onFilterOut = useCallback( - (event: React.MouseEvent) => - onCellFilterAdded({ key: field.name, operator: FILTER_OUT_OPERATOR, value: cell.value }), + (event: React.MouseEvent) => { + if (onCellFilterAdded) { + onCellFilterAdded({ key: field.name, operator: FILTER_OUT_OPERATOR, value: cell.value }); + } + }, [cell, field, onCellFilterAdded] ); diff --git a/packages/grafana-ui/src/components/Table/types.ts b/packages/grafana-ui/src/components/Table/types.ts index 82441536f51..871f746c1be 100644 --- a/packages/grafana-ui/src/components/Table/types.ts +++ b/packages/grafana-ui/src/components/Table/types.ts @@ -29,7 +29,7 @@ export interface TableCellProps extends CellProps { tableStyles: TableStyles; cellProps: React.DetailedHTMLProps, HTMLDivElement>; field: Field; - onCellFilterAdded: TableFilterActionCallback; + onCellFilterAdded?: TableFilterActionCallback; innerWidth: number; }