diff --git a/packages/twenty-front/src/modules/error-handler/components/GenericErrorFallback.tsx b/packages/twenty-front/src/modules/error-handler/components/GenericErrorFallback.tsx index 87f840369..2109891ac 100644 --- a/packages/twenty-front/src/modules/error-handler/components/GenericErrorFallback.tsx +++ b/packages/twenty-front/src/modules/error-handler/components/GenericErrorFallback.tsx @@ -1,4 +1,6 @@ +import { useEffect, useState } from 'react'; import { FallbackProps } from 'react-error-boundary'; +import { useLocation } from 'react-router-dom'; import { ThemeProvider, useTheme } from '@emotion/react'; import isEmpty from 'lodash.isempty'; import { IconRefresh, THEME_LIGHT } from 'twenty-ui'; @@ -11,6 +13,7 @@ import { AnimatedPlaceholderEmptyTextContainer, AnimatedPlaceholderEmptyTitle, } from '@/ui/layout/animated-placeholder/components/EmptyPlaceholderStyled'; +import { isDeeplyEqual } from '~/utils/isDeeplyEqual'; type GenericErrorFallbackProps = FallbackProps; @@ -18,7 +21,18 @@ export const GenericErrorFallback = ({ error, resetErrorBoundary, }: GenericErrorFallbackProps) => { + const location = useLocation(); + + const [previousLocation] = useState(location); + + useEffect(() => { + if (!isDeeplyEqual(previousLocation, location)) { + resetErrorBoundary(); + } + }, [previousLocation, location, resetErrorBoundary]); + const theme = useTheme(); + return (