Skip to content

Commit

Permalink
fix: date filter duplicated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishiguto committed Oct 16, 2024
1 parent 5540037 commit 6f9c096
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const DatePickerField = ({
const [search, setSearch] = useState<Date | null>(null);

const handleDebouncedSearch = useMemo(
() => debounce(onDebouncedSearchChange, wait),
() => onDebouncedSearchChange && debounce(onDebouncedSearchChange, wait),
[wait, props?.value],
);

Expand All @@ -27,7 +27,7 @@ const DatePickerField = ({
// Keep track of the first render to avoid triggering onDebouncedSearchChange
// on the initial render. Only trigger when the 'value' changes.
if (!firstRender.current) {
handleDebouncedSearch(props?.value ?? search);
handleDebouncedSearch?.(props?.value ?? search);
} else {
firstRender.current = false;
}
Expand All @@ -45,7 +45,7 @@ const DatePickerField = ({
field: {
clearable: true,
onClear: () => {
handleDebouncedSearch(null);
handleDebouncedSearch?.(null);
},
},
textField: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ const FilterSubmodule = (props: Props) => {
options,
value: value as unknown as Date,
onChange: (val: Date | null) => onFilterChange(id, val, false),
onDebouncedSearchChange: (val: Date) => onFilterChange(id, val, true),
};

default:
Expand Down

0 comments on commit 6f9c096

Please sign in to comment.