Skip to content

Commit

Permalink
Merge pull request #259 from chrishiguto/fix/date-picker-duplicated-f…
Browse files Browse the repository at this point in the history
…unctions

fix: date filter duplicated functions
  • Loading branch information
andreneto97 authored Oct 17, 2024
2 parents f2f67b3 + 6f9c096 commit 7f619da
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 7f619da

Please sign in to comment.