Fix navbar folder opening lag by deferring navigation until expand animation completes (#19686)

### Before


https://github.com/user-attachments/assets/7d57aa55-8d4c-43e1-8835-f40206e5e453



### After


https://github.com/user-attachments/assets/2457c8ee-fcb9-41ae-a8f7-08f8c7b4a233

---------

Co-authored-by: Etienne <45695613+etiennejouan@users.noreply.github.com>
This commit is contained in:
Abdul Rahman
2026-04-15 22:01:33 +05:30
committed by GitHub
parent b9605a3003
commit 5eda10760c
@@ -1,5 +1,5 @@
import { styled } from '@linaria/react';
import { useState, type ReactNode } from 'react';
import { useDeferredValue, useState, type ReactNode } from 'react';
import { AnimatedExpandableContainer } from 'twenty-ui/layout';
import { NavigationDrawerItemsCollapsableContainer } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItemsCollapsableContainer';
@@ -25,12 +25,15 @@ export const NavigationMenuItemFolderLayout = ({
}: NavigationMenuItemFolderLayoutProps) => {
const [skipInitialExpandAnimation] = useState(() => isOpen);
const deferredIsOpen = useDeferredValue(isOpen);
const isExpandedForAnimation = isOpen ? deferredIsOpen : false;
return (
<NavigationDrawerItemsCollapsableContainer isGroup={isGroup}>
{header}
<StyledFolderExpandableWrapper>
<AnimatedExpandableContainer
isExpanded={isOpen}
isExpanded={isExpandedForAnimation}
dimension="height"
mode="fit-content"
containAnimation