Skip to content

Commit

Permalink
Merge pull request #1666 from ral-facilities/gfi-1662
Browse files Browse the repository at this point in the history
increase TextFilter debounce timer to 500ms #1662
  • Loading branch information
louise-davies authored Aug 29, 2024
2 parents f1d5830 + 51fe1e8 commit 9077d10
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
);

Expand Down Expand Up @@ -129,6 +128,8 @@ const TextColumnFilter = (props: {
);
};

export const DEBOUNCE_DELAY = 500;

export default TextColumnFilter;

export const useTextFilter = (
Expand Down

0 comments on commit 9077d10

Please sign in to comment.