diff --git a/packages/datagateway-common/src/table/columnFilters/textColumnFilter.component.test.tsx b/packages/datagateway-common/src/table/columnFilters/textColumnFilter.component.test.tsx index 638181b12..25fcda5bb 100644 --- a/packages/datagateway-common/src/table/columnFilters/textColumnFilter.component.test.tsx +++ b/packages/datagateway-common/src/table/columnFilters/textColumnFilter.component.test.tsx @@ -2,6 +2,7 @@ import React from 'react'; import TextColumnFilter, { usePrincipalExperimenterFilter, useTextFilter, + DEBOUNCE_DELAY, } from './textColumnFilter.component'; import { act } from 'react-dom/test-utils'; import { usePushFilter, usePushFilters } from '../../api'; @@ -12,7 +13,6 @@ import userEvent from '@testing-library/user-event'; jest.mock('../../api'); jest.useFakeTimers('modern'); -const DEBOUNCE_DELAY = 250; describe('Text filter component', () => { let user: UserEvent; diff --git a/packages/datagateway-common/src/table/columnFilters/textColumnFilter.component.tsx b/packages/datagateway-common/src/table/columnFilters/textColumnFilter.component.tsx index 672ad6c75..ef931afd8 100644 --- a/packages/datagateway-common/src/table/columnFilters/textColumnFilter.component.tsx +++ b/packages/datagateway-common/src/table/columnFilters/textColumnFilter.component.tsx @@ -24,13 +24,12 @@ const TextColumnFilter = (props: { propValue ? propValue : '' ); const [type, setType] = React.useState(propType ? propType : 'include'); - - // Debounce the updating of the column filter by 250 milliseconds. + // Debounce the updating of the column filter by 500 milliseconds. const updateValue = React.useMemo( () => debounce((value: string) => { onChange(value === '' ? null : { value: value, type: type }); - }, 250), + }, DEBOUNCE_DELAY), [onChange, type] ); @@ -129,6 +128,8 @@ const TextColumnFilter = (props: { ); }; +export const DEBOUNCE_DELAY = 500; + export default TextColumnFilter; export const useTextFilter = (