Files
twenty/packages/twenty-front/src/modules/app/hooks/useExecuteTasksOnAnyLocationChange.ts
T
Lucas Bordeau f8f11894e8 Introduce generic way to close any open dropdown on page location change (#11504)
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
2025-04-10 16:00:50 +02:00

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 };
};