diff --git a/packages/main/src/components/AnalyticalTable/index.tsx b/packages/main/src/components/AnalyticalTable/index.tsx index 6c95a6f705b..5345e434964 100644 --- a/packages/main/src/components/AnalyticalTable/index.tsx +++ b/packages/main/src/components/AnalyticalTable/index.tsx @@ -188,10 +188,14 @@ const AnalyticalTable = forwardRef(null); const scrollContainerRef = useRef(null); - const dedupedOnFilter = useMemo(() => debounce(onFilter, 0), [onFilter]); + const dedupedOnFilter = useMemo( + () => (typeof onFilter === 'function' ? debounce(onFilter, 0) : undefined), + [onFilter], + ); + useEffect( () => () => { - dedupedOnFilter.cancel(); + dedupedOnFilter?.cancel(); }, [dedupedOnFilter], ); diff --git a/packages/main/src/components/AnalyticalTable/tableReducer/stateReducer.ts b/packages/main/src/components/AnalyticalTable/tableReducer/stateReducer.ts index 83341bd6707..fa8dba41345 100644 --- a/packages/main/src/components/AnalyticalTable/tableReducer/stateReducer.ts +++ b/packages/main/src/components/AnalyticalTable/tableReducer/stateReducer.ts @@ -28,13 +28,17 @@ export const stateReducer = (state, action, _prevState, instance: TableInstance) }; } switch (action.type) { - case 'setFilter': - instance.webComponentsReactProperties.onFilter({ - filters: state.filters, - value: action.filterValue, - columnId: action.columnId, - }); + case 'setFilter': { + const { onFilter } = instance.webComponentsReactProperties; + if (typeof onFilter === 'function') { + instance.webComponentsReactProperties.onFilter({ + filters: state.filters, + value: action.filterValue, + columnId: action.columnId, + }); + } return state; + } case 'toggleRowExpanded': // this flag disables scrolling to the top of the table if a table is collapsed if (!state.expanded[action.id]) {