From b9b62b2f1a2c333df4ffd3b5378fd202c331375c Mon Sep 17 00:00:00 2001 From: Andrew Tate Date: Thu, 18 Aug 2022 20:09:46 -0500 Subject: [PATCH] switch to first page before filtering --- .../datatable/components/table_basic.tsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.tsx b/x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.tsx index fe0a7da701f2a..c86b960356d72 100644 --- a/x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/components/table_basic.tsx @@ -177,10 +177,19 @@ export const DatatableComponent = (props: DatatableRenderProps) => { [dispatchEvent] ); - const handleFilterClick = useMemo( - () => (isInteractive ? createGridFilterHandler(firstTableRef, onClickValue) : undefined), - [firstTableRef, onClickValue, isInteractive] - ); + const handleFilterClick = useMemo(() => { + const handler = isInteractive + ? createGridFilterHandler(firstTableRef, onClickValue) + : undefined; + if (handler) { + const wrappedHandler: typeof handler = (...args) => { + // update pagination + onChangePage(0); + return handler(...args); + }; + return wrappedHandler; + } + }, [firstTableRef, onClickValue, isInteractive, onChangePage]); const handleTransposedColumnClick = useMemo( () =>