f8f11894e8
In this PR we introduce a generic way to close any open dropdown idempotently, with the hook useCloseAnyOpenDropdown. We also introduce a generic hook useExecuteTasksOnAnyLocationChange that is called each time the page location changes. This way we can close any open dropdown when the page location changes, which fixes the original issue of having advanced filter dropdown staying open between page changes. Fixes https://github.com/twentyhq/core-team-issues/issues/659
17 lines
460 B
TypeScript
17 lines
460 B
TypeScript
import { useCloseAnyOpenDropdown } from '@/ui/layout/dropdown/hooks/useCloseAnyOpenDropdown';
|
|
|
|
export const useExecuteTasksOnAnyLocationChange = () => {
|
|
const { closeAnyOpenDropdown } = useCloseAnyOpenDropdown();
|
|
|
|
/**
|
|
* Be careful to put idempotent tasks here.
|
|
*
|
|
* Because it might be called multiple times.
|
|
*/
|
|
const executeTasksOnAnyLocationChange = () => {
|
|
closeAnyOpenDropdown();
|
|
};
|
|
|
|
return { executeTasksOnAnyLocationChange };
|
|
};
|