Skip to content

The open alternative to Salesforce, designed for AI.

Drop the app-to-settings cross-fade (#25249)

Félix Malfaita68082705cc4
diff --git a/packages/twenty-front/src/modules/app/routing/utils/getWorkspaceRouteObjectsForSurface.tsx b/packages/twenty-front/src/modules/app/routing/utils/getWorkspaceRouteObjectsForSurface.tsx
index 265eca0e681..e81ada6e422 100644
--- a/packages/twenty-front/src/modules/app/routing/utils/getWorkspaceRouteObjectsForSurface.tsx
+++ b/packages/twenty-front/src/modules/app/routing/utils/getWorkspaceRouteObjectsForSurface.tsx
@@ -43,13 +43,10 @@ const getWorkspaceRouteObjects = (
];
});
-// The main surface hosts its route context store once, above the page
-// transition, in MainAppLayoutWithSidePanel: the transition keeps the page
-// being left mounted while the next one enters, and a provider inside each
-// page would leave two of them writing the same store from different routes.
-// The side panel renders its routes against its own location, which only the
-// routed tree can read, and it remounts per location, so its provider lives
-// inside the tree.
+// Each surface has exactly one route context store provider. The main surface
+// hosts it in MainAppLayoutWithSidePanel, above its routes. The side panel
+// renders its routes against its own location, which only the routed tree can
+// read, and it remounts per location, so its provider lives inside the tree.
export const getWorkspaceRouteObjectsForSurface = (
routeObjects: WorkspaceRouteObject[],
surface: WorkspaceSurfaceType,
diff --git a/packages/twenty-front/src/modules/ui/layout/page/components/MainAppLayoutWithSidePanel.tsx b/packages/twenty-front/src/modules/ui/layout/page/components/MainAppLayoutWithSidePanel.tsx
index 3b7ccd62832..9260d2f5659 100644
--- a/packages/twenty-front/src/modules/ui/layout/page/components/MainAppLayoutWithSidePanel.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/page/components/MainAppLayoutWithSidePanel.tsx
@@ -5,18 +5,7 @@ import { SidePanelForDesktop } from '@/side-panel/components/SidePanelForDesktop
import { SidePanelPathUrlSyncEffect } from '@/side-panel/routing/components/SidePanelPathUrlSyncEffect';
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
import { styled } from '@linaria/react';
-import { AnimatePresence, motion } from 'framer-motion';
-import { useEffect, useState } from 'react';
-import { useLocation, useOutlet } from 'react-router-dom';
-import { isDefined } from 'twenty-shared/utils';
-import { isSettingsPath } from '~/utils/isSettingsPath';
-
-const ROUTE_SECTION_DATA_ATTRIBUTE = 'data-main-app-route-section';
-
-const APP_TO_SETTINGS_TRANSITION_DURATION_IN_SECONDS = 0.3;
-
-const getMainAppLayoutRouteSection = (pathname: string) =>
- isSettingsPath(pathname) ? 'settings' : 'app';
+import { Outlet } from 'react-router-dom';
const StyledRow = styled.div`
display: flex;
@@ -53,76 +42,6 @@ const StyledContent = styled.div`
}
`;
-const StyledContentTransitionContainer = styled.div`
- display: grid;
- flex: 1 1 0;
- min-height: 0;
- min-width: 0;
- overflow: hidden;
-
- @media print {
- display: block;
- min-height: auto;
- min-width: auto;
- overflow: visible;
- }
-`;
-
-const StyledContentTransitionPage = styled(motion.div)`
- display: flex;
- grid-area: 1 / 1;
- min-height: 0;
- min-width: 0;
- width: 100%;
-
- @media print {
- display: block;
- min-height: auto;
- min-width: auto;
- }
-`;
-
-const MainAppLayoutOutlet = () => {
- const { pathname } = useLocation();
- const outlet = useOutlet();
- const routeSection = getMainAppLayoutRouteSection(pathname);
- const [containerElement, setContainerElement] =
- useState<HTMLDivElement | null>(null);
-
- useEffect(() => {
- if (!isDefined(containerElement)) {
- return;
- }
-
- Array.from(containerElement.children).forEach((child) => {
- if (child instanceof HTMLElement) {
- child.inert =
- child.getAttribute(ROUTE_SECTION_DATA_ATTRIBUTE) !== routeSection;
- }
- });
- }, [containerElement, routeSection]);
-
- return (
- <StyledContentTransitionContainer ref={setContainerElement}>
- <AnimatePresence initial={false}>
- <StyledContentTransitionPage
- key={routeSection}
- {...{ [ROUTE_SECTION_DATA_ATTRIBUTE]: routeSection }}
- initial={{ opacity: 0, y: 4 }}
- animate={{ opacity: 1, y: 0 }}
- exit={{ opacity: 0, y: -4, pointerEvents: 'none' }}
- transition={{
- duration: APP_TO_SETTINGS_TRANSITION_DURATION_IN_SECONDS,
- ease: 'easeInOut',
- }}
- >
- {outlet}
- </StyledContentTransitionPage>
- </AnimatePresence>
- </StyledContentTransitionContainer>
- );
-};
-
export const MainAppLayoutWithSidePanel = () => {
const isMobile = useIsMobile();
@@ -133,7 +52,7 @@ export const MainAppLayoutWithSidePanel = () => {
<RouteContextStoreProvider />
<SidePanelPathUrlSyncEffect />
<StyledContent>
- <MainAppLayoutOutlet />
+ <Outlet />
</StyledContent>
{isMobile ? <CommandMenuForMobile /> : <SidePanelForDesktop />}
</StyledRow>
diff --git a/packages/twenty-front/src/modules/ui/layout/page/components/__tests__/MainAppLayoutWithSidePanel.test.tsx b/packages/twenty-front/src/modules/ui/layout/page/components/__tests__/MainAppLayoutWithSidePanel.test.tsx
index 58136fba436..0b224c7cf79 100644
--- a/packages/twenty-front/src/modules/ui/layout/page/components/__tests__/MainAppLayoutWithSidePanel.test.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/page/components/__tests__/MainAppLayoutWithSidePanel.test.tsx
@@ -84,11 +84,7 @@ const MainSurfaceRoutes = () =>
]);
describe('MainAppLayoutWithSidePanel', () => {
- // Switching between the app and settings sections keeps the page being left
- // mounted while the next one animates in. If each page carried its own route
- // context store provider, the stale one would keep writing the main store
- // from a route that no longer matches the location, fighting the new one.
- it('keeps a single route context store provider on the main surface across a section switch', async () => {
+ it('hosts one route context store provider that reads the matched leaf params', async () => {
render(
<MemoryRouter initialEntries={['/objects/companies']}>
<NavigateProbeEffect />