From 21b1909428a2b9188a006ddf01f46bf8baa0afab Mon Sep 17 00:00:00 2001 From: bosiraphael Date: Tue, 18 Feb 2025 11:17:10 +0100 Subject: [PATCH 1/9] Unify the open and close command menu button --- .../components/CommandMenuContainer.tsx | 1 + .../components/CommandMenuTopBar.tsx | 22 +++++++++-- .../PageHeaderOpenCommandMenuButton.tsx | 37 ++++++++++++++----- 3 files changed, 46 insertions(+), 14 deletions(-) diff --git a/packages/twenty-front/src/modules/command-menu/components/CommandMenuContainer.tsx b/packages/twenty-front/src/modules/command-menu/components/CommandMenuContainer.tsx index 3a646f947232..54ad9058764b 100644 --- a/packages/twenty-front/src/modules/command-menu/components/CommandMenuContainer.tsx +++ b/packages/twenty-front/src/modules/command-menu/components/CommandMenuContainer.tsx @@ -65,6 +65,7 @@ export const CommandMenuContainer = ({ callback: closeCommandMenu, listenerId: 'COMMAND_MENU_LISTENER_ID', hotkeyScope: AppHotkeyScope.CommandMenuOpen, + excludeClassNames: ['page-header-command-menu-button'], }); const isMobile = useIsMobile(); diff --git a/packages/twenty-front/src/modules/command-menu/components/CommandMenuTopBar.tsx b/packages/twenty-front/src/modules/command-menu/components/CommandMenuTopBar.tsx index c3fd69d38f60..82c837e6dc0e 100644 --- a/packages/twenty-front/src/modules/command-menu/components/CommandMenuTopBar.tsx +++ b/packages/twenty-front/src/modules/command-menu/components/CommandMenuTopBar.tsx @@ -16,6 +16,7 @@ import { useTheme } from '@emotion/react'; import styled from '@emotion/styled'; import { useLingui } from '@lingui/react/macro'; import { useMemo, useRef } from 'react'; +import { useLocation } from 'react-router-dom'; import { useRecoilState, useRecoilValue } from 'recoil'; import { isDefined } from 'twenty-shared'; import { @@ -80,6 +81,10 @@ const StyledCloseButtonContainer = styled.div` justify-content: center; `; +const StyledCloseButtonWrapper = styled.div<{ isVisible: boolean }>` + visibility: ${({ isVisible }) => (isVisible ? 'visible' : 'hidden')}; +`; + export const CommandMenuTopBar = () => { const [commandMenuSearch, setCommandMenuSearch] = useRecoilState( commandMenuSearchState, @@ -123,6 +128,11 @@ export const CommandMenuTopBar = () => { }); }, [commandMenuNavigationStack, theme.icon.size.sm]); + const location = useLocation(); + const isButtonVisible = + !location.pathname.startsWith('/objects/') && + !location.pathname.startsWith('/object/'); + return ( @@ -162,7 +172,7 @@ export const CommandMenuTopBar = () => { )} {!isMobile && ( - <> + {isCommandMenuV2Enabled ? (