Skip to content

Commit

Permalink
fix debouncer
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro committed May 24, 2021
1 parent d9dc6b8 commit 5996b58
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ export const FiltersConfigForm: React.FC<FiltersConfigFormProps> = ({
?.datasourceCount;
const hasColumn =
hasDataset && !FILTERS_WITHOUT_COLUMN.includes(formFilter?.filterType);
// @ts-ignore
const enableNoResults = !!nativeFilterItems[formFilter?.filterType]?.value
?.enableNoResults;
const datasetId = formFilter?.dataset?.value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
t,
tn,
} from '@superset-ui/core';
import React, { useEffect, useReducer, useState } from 'react';
import React, { useCallback, useEffect, useReducer, useState } from 'react';
import { Select } from 'src/common/components';
import { debounce } from 'lodash';
import { SLOW_DEBOUNCE } from 'src/constants';
Expand Down Expand Up @@ -123,14 +123,17 @@ export default function PluginFilterSelect(props: PluginFilterSelectProps) {
: {},
);

const debouncedOwnStateFunc = debounce((val: string) => {
dispatchDataMask({
type: 'ownState',
ownState: {
search: val,
},
});
}, SLOW_DEBOUNCE);
const debouncedOwnStateFunc = useCallback(
debounce((val: string) => {
dispatchDataMask({
type: 'ownState',
ownState: {
search: val,
},
});
}, SLOW_DEBOUNCE),
[],
);

const searchWrapper = (val: string) => {
if (searchAllOptions) {
Expand Down

0 comments on commit 5996b58

Please sign in to comment.