Skip to content

The open alternative to Salesforce, designed for AI.

Replace record summary cards with an identifier bar (#24936)

Thomas des Francs1b33eb048396
diff --git a/packages/twenty-front/src/modules/object-record/record-show/components/RecordIdentifierBarTitle.tsx b/packages/twenty-front/src/modules/object-record/record-show/components/RecordIdentifierBarTitle.tsx
index 9fab7089ff8..8d841f7c7e4 100644
--- a/packages/twenty-front/src/modules/object-record/record-show/components/RecordIdentifierBarTitle.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-show/components/RecordIdentifierBarTitle.tsx
@@ -17,11 +17,13 @@ const StyledFileInput = styled.input`
type RecordIdentifierBarTitleProps = {
objectNameSingular: string;
objectRecordId: string;
+ variant?: 'record-page' | 'side-panel';
};
export const RecordIdentifierBarTitle = ({
objectNameSingular,
objectRecordId,
+ variant = 'record-page',
}: RecordIdentifierBarTitleProps) => {
const { recordIdentifier, onUploadPicture, titleFieldContextValue } =
useRecordIdentifierTitle({
@@ -38,12 +40,17 @@ export const RecordIdentifierBarTitle = ({
};
const isAvatarEditable = isDefined(onUploadPicture);
+ const isInSidePanel = variant === 'side-panel';
const title = (
<FieldContext.Provider value={titleFieldContextValue}>
<RecordTitleCell
sizeVariant="sm"
- containerType={RecordTitleCellContainerType.PageHeader}
+ containerType={
+ isInSidePanel
+ ? RecordTitleCellContainerType.PageHeader
+ : RecordTitleCellContainerType.ShowPage
+ }
/>
</FieldContext.Provider>
);
@@ -51,6 +58,7 @@ export const RecordIdentifierBarTitle = ({
return (
<>
<HeaderIdentifier
+ fontSize={isInSidePanel ? 'md' : 'lg'}
avatar={{
avatarUrl: getAbsoluteImageUrl(recordIdentifier?.avatarUrl ?? ''),
onClick: isAvatarEditable
@@ -63,7 +71,7 @@ export const RecordIdentifierBarTitle = ({
title={
// A writable title has to stay click-to-edit, so only a read-only one
// can double as a link to the record page.
- titleFieldContextValue.isRecordFieldReadOnly ? (
+ isInSidePanel && titleFieldContextValue.isRecordFieldReadOnly ? (
<UndecoratedLink
to={getAppPath(AppPath.RecordShowPage, {
objectNameSingular,
diff --git a/packages/twenty-front/src/modules/object-record/record-show/components/SummaryCard.tsx b/packages/twenty-front/src/modules/object-record/record-show/components/SummaryCard.tsx
deleted file mode 100644
index 87dd88b1a77..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-show/components/SummaryCard.tsx
+++ /dev/null
@@ -1,123 +0,0 @@
-import { allowRequestsToTwentyIconsState } from '@/client-config/states/allowRequestsToTwentyIcons';
-import { useLabelIdentifierFieldMetadataItem } from '@/object-metadata/hooks/useLabelIdentifierFieldMetadataItem';
-import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
-import { useIsRecordFieldReadOnly } from '@/object-record/read-only/hooks/useIsRecordFieldReadOnly';
-import { FieldContext } from '@/object-record/record-field/ui/contexts/FieldContext';
-import { useRecordImageIdentifierUpload } from '@/object-record/record-show/hooks/useRecordImageIdentifierUpload';
-import { useRecordShowContainerActions } from '@/object-record/record-show/hooks/useRecordShowContainerActions';
-import { useRecordShowContainerData } from '@/object-record/record-show/hooks/useRecordShowContainerData';
-import { recordStoreFamilySelector } from '@/object-record/record-store/states/selectors/recordStoreFamilySelector';
-import { recordStoreIdentifierFamilySelector } from '@/object-record/record-store/states/selectors/recordStoreIdentifierFamilySelector';
-import { RecordTitleCell } from '@/object-record/record-title-cell/components/RecordTitleCell';
-import { RecordTitleCellContainerType } from '@/object-record/record-title-cell/types/RecordTitleCellContainerType';
-import { ShowPageSummaryCard } from '@/ui/layout/show-page/components/ShowPageSummaryCard';
-import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
-import { useAtomFamilySelectorValue } from '@/ui/utilities/state/jotai/hooks/useAtomFamilySelectorValue';
-import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
-import { isDefined } from 'twenty-shared/utils';
-import { FieldMetadataType } from '~/generated-metadata/graphql';
-
-type SummaryCardProps = {
- objectNameSingular: string;
- objectRecordId: string;
- isInSidePanel: boolean;
-};
-
-// TODO: refactor all this hierarchy of side panel / show page record to avoid drill down
-export const SummaryCard = ({
- objectNameSingular,
- objectRecordId,
- isInSidePanel,
-}: SummaryCardProps) => {
- const { recordLoading } = useRecordShowContainerData({
- objectRecordId,
- });
-
- const recordCreatedAt = useAtomFamilySelectorValue(
- recordStoreFamilySelector,
- {
- recordId: objectRecordId,
- fieldName: 'createdAt',
- },
- ) as string | null;
- const allowRequestsToTwentyIcons = useAtomStateValue(
- allowRequestsToTwentyIconsState,
- );
-
- const { useUpdateOneObjectRecordMutation } = useRecordShowContainerActions({
- objectNameSingular,
- });
-
- const { onUploadPicture } = useRecordImageIdentifierUpload({
- objectNameSingular,
- recordId: objectRecordId,
- });
-
- const isMobile = useIsMobile() || isInSidePanel;
-
- const recordIdentifier = useAtomFamilySelectorValue(
- recordStoreIdentifierFamilySelector,
- {
- recordId: objectRecordId,
- allowRequestsToTwentyIcons,
- },
- );
-
- const { objectMetadataItem } = useObjectMetadataItem({
- objectNameSingular,
- });
-
- const { labelIdentifierFieldMetadataItem } =
- useLabelIdentifierFieldMetadataItem({
- objectNameSingular,
- });
-
- const isTitleReadOnly = useIsRecordFieldReadOnly({
- recordId: objectRecordId,
- fieldMetadataId: labelIdentifierFieldMetadataItem?.id ?? '',
- objectMetadataId: objectMetadataItem.id,
- });
-
- return (
- <ShowPageSummaryCard
- isMobile={isMobile}
- id={objectRecordId}
- logoOrAvatar={recordIdentifier?.avatarUrl ?? ''}
- avatarPlaceholder={recordIdentifier?.name ?? ''}
- date={recordCreatedAt ?? ''}
- loading={recordLoading || !isDefined(recordCreatedAt)}
- title={
- <FieldContext.Provider
- value={{
- recordId: objectRecordId,
- isLabelIdentifier: false,
- fieldDefinition: {
- type:
- labelIdentifierFieldMetadataItem?.type ||
- FieldMetadataType.TEXT,
- iconName: '',
- fieldMetadataId: labelIdentifierFieldMetadataItem?.id ?? '',
- label: labelIdentifierFieldMetadataItem?.label || '',
- metadata: {
- fieldName: labelIdentifierFieldMetadataItem?.name || '',
- objectMetadataNameSingular: objectNameSingular,
- },
- defaultValue: labelIdentifierFieldMetadataItem?.defaultValue,
- },
- useUpdateRecord: useUpdateOneObjectRecordMutation,
- isCentered: !isMobile,
- isDisplayModeFixHeight: true,
- isRecordFieldReadOnly: isTitleReadOnly,
- }}
- >
- <RecordTitleCell
- sizeVariant="md"
- containerType={RecordTitleCellContainerType.ShowPage}
- />
- </FieldContext.Provider>
- }
- avatarType={recordIdentifier?.avatarType ?? 'rounded'}
- onUploadPicture={onUploadPicture}
- />
- );
-};
diff --git a/packages/twenty-front/src/modules/page-layout/components/PageLayoutLeftPanel.tsx b/packages/twenty-front/src/modules/page-layout/components/PageLayoutLeftPanel.tsx
index a4b8704cccb..55ec56f0dfe 100644
--- a/packages/twenty-front/src/modules/page-layout/components/PageLayoutLeftPanel.tsx
+++ b/packages/twenty-front/src/modules/page-layout/components/PageLayoutLeftPanel.tsx
@@ -1,4 +1,3 @@
-import { SummaryCard } from '@/object-record/record-show/components/SummaryCard';
import { PageLayoutContent } from '@/page-layout/components/PageLayoutContent';
import { PageLayoutScrollResetEffect } from '@/page-layout/components/PageLayoutScrollResetEffect';
import { PageLayoutContentProvider } from '@/page-layout/contexts/PageLayoutContentContext';
@@ -19,11 +18,10 @@ const StyledContainer = styled.div`
background: var(--record-card-background-color);
border-bottom-left-radius: 8px;
border-right: 1px solid ${themeCssVariables.border.color.medium};
- border-top-left-radius: 8px;
box-sizing: border-box;
display: grid;
grid-template-columns: minmax(0, 1fr);
- grid-template-rows: auto 1fr;
+ grid-template-rows: minmax(0, 1fr);
height: 100%;
.page-layout-scroll-wrapper {
@@ -71,12 +69,9 @@ export const PageLayoutLeftPanel = ({
scrollWrapperInstanceId={scrollWrapperInstanceId}
targetRecordId={targetRecordIdentifier.id}
/>
- <SummaryCard
- objectNameSingular={targetRecordIdentifier.targetObjectNameSingular}
- objectRecordId={targetRecordIdentifier.id}
- isInSidePanel={isInSidePanel}
- />
+ {/* The pinned left panel is always a column of cards, even with a single
+ widget: solo presentation is a main-tab-area concept. */}
<PageLayoutContentProvider
value={{
tabId: pinnedLeftTabId,
diff --git a/packages/twenty-front/src/modules/page-layout/components/PageLayoutRecordIdentifierBar.tsx b/packages/twenty-front/src/modules/page-layout/components/PageLayoutRecordIdentifierBar.tsx
new file mode 100644
index 00000000000..f2e07f7ab61
--- /dev/null
+++ b/packages/twenty-front/src/modules/page-layout/components/PageLayoutRecordIdentifierBar.tsx
@@ -0,0 +1,129 @@
+import { RecordIdentifierBarCreatedAt } from '@/object-record/record-show/components/RecordIdentifierBarCreatedAt';
+import { RecordIdentifierBarTitle } from '@/object-record/record-show/components/RecordIdentifierBarTitle';
+import { PAGE_LAYOUT_LEFT_PANEL_CONTAINER_WIDTH } from '@/page-layout/constants/PageLayoutLeftPanelContainerWidth';
+import { PAGE_LAYOUT_RECORD_IDENTIFIER_BAR_HEIGHT } from '@/page-layout/constants/PageLayoutRecordIdentifierBarHeight';
+import { useOpenPageLayoutTabSettings } from '@/page-layout/hooks/useOpenPageLayoutTabSettings';
+import { type PageLayoutTab } from '@/page-layout/types/PageLayoutTab';
+import { type TargetRecordIdentifier } from '@/ui/layout/contexts/TargetRecordIdentifier';
+import { styled } from '@linaria/react';
+import { useLingui } from '@lingui/react/macro';
+import { type ReactNode } from 'react';
+import { isDefined } from 'twenty-shared/utils';
+import { IconPinned } from 'twenty-ui/icon';
+import { IconButtonWithTooltip } from 'twenty-ui/input';
+import { TooltipDelay } from 'twenty-ui/surfaces';
+import { themeCssVariables } from 'twenty-ui/theme-constants';
+
+const SIDE_TRACK = `min(${PAGE_LAYOUT_LEFT_PANEL_CONTAINER_WIDTH}px, calc(100% / 3))`;
+
+// Equal side tracks center the tabs independently of the record name. Their
+// width stays independent of visible tabs so overflow can recover on resize.
+const StyledBar = styled.div<{ hasPinnedTab: boolean }>`
+ align-items: stretch;
+ background: ${themeCssVariables.background.secondary};
+ // The bottom line sits inside the box so the tab strip can fill the whole row
+ // and land its active indicator on that line rather than above it.
+ box-shadow: inset 0 -1px 0 ${themeCssVariables.border.color.light};
+ box-sizing: border-box;
+ display: grid;
+ grid-template-columns: ${({ hasPinnedTab }) =>
+ hasPinnedTab
+ ? `${PAGE_LAYOUT_LEFT_PANEL_CONTAINER_WIDTH}px minmax(0, 1fr)`
+ : `${SIDE_TRACK} minmax(0, 1fr) ${SIDE_TRACK}`};
+ height: ${PAGE_LAYOUT_RECORD_IDENTIFIER_BAR_HEIGHT}px;
+ width: 100%;
+`;
+
+const StyledIdentifierCell = styled.div<{ hasPinnedTab: boolean }>`
+ align-items: center;
+ border-right: ${({ hasPinnedTab }) =>
+ hasPinnedTab
+ ? `1px solid ${themeCssVariables.border.color.medium}`
+ : 'none'};
+ box-sizing: border-box;
+ display: flex;
+ gap: ${themeCssVariables.spacing[2]};
+ justify-content: space-between;
+ min-width: 0;
+ padding-left: ${themeCssVariables.spacing[3]};
+ padding-right: ${themeCssVariables.spacing[2]};
+`;
+
+// The pinned-tab control stays over the left panel when editing.
+const StyledPinnedTab = styled.div`
+ align-items: center;
+ display: flex;
+ flex-shrink: 0;
+ height: 100%;
+`;
+
+const StyledTabsCell = styled.div`
+ align-items: stretch;
+ display: flex;
+ min-width: 0;
+
+ @media print {
+ display: none;
+ }
+`;
+
+const StyledCreatedAtCell = styled.div`
+ align-items: center;
+ display: flex;
+ justify-content: flex-end;
+ min-width: 0;
+ padding-left: ${themeCssVariables.spacing[2]};
+ padding-right: ${themeCssVariables.spacing[3]};
+`;
+
+type PageLayoutRecordIdentifierBarProps = {
+ targetRecordIdentifier: TargetRecordIdentifier;
+ pinnedTab?: Pick<PageLayoutTab, 'id' | 'title'>;
+ isPinnedTabEditable?: boolean;
+ tabList?: ReactNode;
+};
+
+export const PageLayoutRecordIdentifierBar = ({
+ targetRecordIdentifier,
+ pinnedTab,
+ isPinnedTabEditable = false,
+ tabList,
+}: PageLayoutRecordIdentifierBarProps) => {
+ const { t } = useLingui();
+ const { openTabSettings } = useOpenPageLayoutTabSettings();
+ const hasPinnedTab = isDefined(pinnedTab);
+ const createdAt = (
+ <RecordIdentifierBarCreatedAt objectRecordId={targetRecordIdentifier.id} />
+ );
+
+ return (
+ <StyledBar hasPinnedTab={hasPinnedTab}>
+ <StyledIdentifierCell hasPinnedTab={hasPinnedTab}>
+ <RecordIdentifierBarTitle
+ objectNameSingular={targetRecordIdentifier.targetObjectNameSingular}
+ objectRecordId={targetRecordIdentifier.id}
+ />
+
+ {hasPinnedTab && createdAt}
+
+ {isPinnedTabEditable && isDefined(pinnedTab) && (
+ <StyledPinnedTab>
+ <IconButtonWithTooltip
+ Icon={IconPinned}
+ ariaLabel={t`Edit pinned tab: ${pinnedTab.title}`}
+ onClick={() => openTabSettings(pinnedTab.id)}
+ tooltipContent={t`Pinned tab, always shown on the left`}
+ tooltipDelay={TooltipDelay.shortDelay}
+ size="small"
+ variant="tertiary"
+ />
+ </StyledPinnedTab>
+ )}
+ </StyledIdentifierCell>
+
+ <StyledTabsCell>{tabList}</StyledTabsCell>
+
+ {!hasPinnedTab && <StyledCreatedAtCell>{createdAt}</StyledCreatedAtCell>}
+ </StyledBar>
+ );
+};
diff --git a/packages/twenty-front/src/modules/page-layout/components/PageLayoutSingleTabRenderer.tsx b/packages/twenty-front/src/modules/page-layout/components/PageLayoutSingleTabRenderer.tsx
index e7ab5da6a4d..0fcfdc35c1a 100644
--- a/packages/twenty-front/src/modules/page-layout/components/PageLayoutSingleTabRenderer.tsx
+++ b/packages/twenty-front/src/modules/page-layout/components/PageLayoutSingleTabRenderer.tsx
@@ -1,9 +1,11 @@
-import { SummaryCard } from '@/object-record/record-show/components/SummaryCard';
+import { RecordIdentifierBarCreatedAt } from '@/object-record/record-show/components/RecordIdentifierBarCreatedAt';
+import { RecordIdentifierBarTitle } from '@/object-record/record-show/components/RecordIdentifierBarTitle';
import { PageLayoutWidgetDndProvider } from '@/page-layout/components/dnd/PageLayoutWidgetDndProvider';
import { PageLayoutContent } from '@/page-layout/components/PageLayoutContent';
import { PageLayoutEditModeProvider } from '@/page-layout/components/PageLayoutEditModeProvider';
import { PageLayoutInitializationQueryEffect } from '@/page-layout/components/PageLayoutInitializationQueryEffect';
import { PageLayoutRecordPageCustomizationSessionRegistrationEffect } from '@/page-layout/components/PageLayoutRecordPageCustomizationSessionRegistrationEffect';
+import { PAGE_LAYOUT_RECORD_IDENTIFIER_BAR_HEIGHT } from '@/page-layout/constants/PageLayoutRecordIdentifierBarHeight';
import { PageLayoutContentProvider } from '@/page-layout/contexts/PageLayoutContentContext';
import { useCurrentPageLayoutOrThrow } from '@/page-layout/hooks/useCurrentPageLayoutOrThrow';
import { useIsPageLayoutInEditMode } from '@/page-layout/hooks/useIsPageLayoutInEditMode';
@@ -19,7 +21,22 @@ import { useLayoutRenderingContext } from '@/ui/layout/contexts/LayoutRenderingC
import { useTargetRecord } from '@/ui/layout/contexts/useTargetRecord';
import { TabListComponentInstanceContext } from '@/ui/layout/tab-list/states/contexts/TabListComponentInstanceContext';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
+import { styled } from '@linaria/react';
import { isDefined } from 'twenty-shared/utils';
+import { themeCssVariables } from 'twenty-ui/theme-constants';
+
+const StyledRecordIdentifierBar = styled.div`
+ align-items: center;
+ background: ${themeCssVariables.background.secondary};
+ border-bottom: 1px solid ${themeCssVariables.border.color.light};
+ box-sizing: border-box;
+ display: flex;
+ gap: ${themeCssVariables.spacing[2]};
+ height: ${PAGE_LAYOUT_RECORD_IDENTIFIER_BAR_HEIGHT}px;
+ justify-content: space-between;
+ min-width: 0;
+ padding: 0 ${themeCssVariables.spacing[3]};
+`;
type PageLayoutSingleTabRendererProps = {
pageLayoutId: string;
@@ -40,7 +57,6 @@ const PageLayoutSingleTabRendererContent = () => {
const PageLayoutSingleTabRendererInner = () => {
const { currentPageLayout } = useCurrentPageLayoutOrThrow();
const targetRecordIdentifier = useTargetRecord();
- const { isInSidePanel } = useLayoutRenderingContext();
const sortedActiveTabs = sortTabsByPosition(
currentPageLayout.tabs.filter((tab) => tab.isActive),
@@ -49,11 +65,15 @@ const PageLayoutSingleTabRendererInner = () => {
return (
<>
- <SummaryCard
- objectNameSingular={targetRecordIdentifier.targetObjectNameSingular}
- objectRecordId={targetRecordIdentifier.id}
- isInSidePanel={isInSidePanel}
- />
+ <StyledRecordIdentifierBar>
+ <RecordIdentifierBarTitle
+ objectNameSingular={targetRecordIdentifier.targetObjectNameSingular}
+ objectRecordId={targetRecordIdentifier.id}
+ />
+ <RecordIdentifierBarCreatedAt
+ objectRecordId={targetRecordIdentifier.id}
+ />
+ </StyledRecordIdentifierBar>
{isDefined(firstTab) && (
<PageLayoutSingleTabRendererTabContent firstTabId={firstTab.id} />
diff --git a/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabList.tsx b/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabList.tsx
index 315b35e9173..85899d171ba 100644
--- a/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabList.tsx
+++ b/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabList.tsx
@@ -1,4 +1,5 @@
import { useDragDropMonitor } from '@dnd-kit/react';
+import { css } from '@linaria/core';
import { styled } from '@linaria/react';
import { useLingui } from '@lingui/react/macro';
import { useCallback, useMemo } from 'react';
@@ -12,6 +13,8 @@ import { useOpenDropdown } from '@/ui/layout/dropdown/hooks/useOpenDropdown';
import { TabListHiddenMeasurements } from '@/ui/layout/tab-list/components/TabListHiddenMeasurements';
import { TAB_LIST_GAP } from '@/ui/layout/tab-list/constants/TabListGap';
import { TAB_LIST_HEIGHT } from '@/ui/layout/tab-list/constants/TabListHeight';
+import { TAB_LIST_HORIZONTAL_PADDING } from '@/ui/layout/tab-list/constants/TabListPadding';
+import { TAB_LIST_ROW_HEIGHT_CSS_VARIABLE } from '@/ui/layout/tab-list/constants/TabListRowHeightCssVariable';
import { useTabListMeasurements } from '@/ui/layout/tab-list/hooks/useTabListMeasurements';
import { activeTabIdComponentState } from '@/ui/layout/tab-list/states/activeTabIdComponentState';
import { TabListComponentInstanceContext } from '@/ui/layout/tab-list/states/contexts/TabListComponentInstanceContext';
@@ -23,11 +26,13 @@ import { useAtomComponentState } from '@/ui/utilities/state/jotai/hooks/useAtomC
import { useSetAtomComponentState } from '@/ui/utilities/state/jotai/hooks/useSetAtomComponentState';
import { PAGE_LAYOUT_TAB_LIST_DROPPABLE_IDS } from '@/page-layout/components/PageLayoutTabListDroppableIds';
+import { PAGE_LAYOUT_RECORD_IDENTIFIER_BAR_HEIGHT } from '@/page-layout/constants/PageLayoutRecordIdentifierBarHeight';
import { PAGE_LAYOUT_TAB_LIST_END_DROP_ZONE_WIDTH } from '@/page-layout/constants/PageLayoutTabListEndDropZoneWidth';
import { PageLayoutTabListNewTabDropdownContent } from '@/page-layout/components/PageLayoutTabListNewTabDropdownContent';
import { PageLayoutTabListReorderableOverflowDropdown } from '@/page-layout/components/PageLayoutTabListReorderableOverflowDropdown';
import { PageLayoutTabListVisibleTabs } from '@/page-layout/components/PageLayoutTabListVisibleTabs';
import { useIsPageLayoutInEditMode } from '@/page-layout/hooks/useIsPageLayoutInEditMode';
+import { useOpenPageLayoutTabSettings } from '@/page-layout/hooks/useOpenPageLayoutTabSettings';
import { PageLayoutComponentInstanceContext } from '@/page-layout/states/contexts/PageLayoutComponentInstanceContext';
import { pageLayoutTabSettingsOpenTabIdComponentState } from '@/page-layout/states/pageLayoutTabSettingsOpenTabIdComponentState';
import { type PageLayoutAddTabStrategy } from '@/page-layout/types/PageLayoutAddTabStrategy';
@@ -35,14 +40,12 @@ import { type PageLayoutTab } from '@/page-layout/types/PageLayoutTab';
import { type PageLayoutWidget } from '@/page-layout/types/PageLayoutWidget';
import { type PageLayoutWidgetDndData } from '@/page-layout/types/PageLayoutWidgetDndData';
import { shouldEnableTabEditingFeatures } from '@/page-layout/utils/shouldEnableTabEditingFeatures';
-import { useNavigatePageLayoutSidePanel } from '@/side-panel/pages/page-layout/hooks/useNavigatePageLayoutSidePanel';
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
import { TabListDropdown } from '@/ui/layout/tab-list/components/TabListDropdown';
import { TabListFromUrlOptionalEffect } from '@/ui/layout/tab-list/components/TabListFromUrlOptionalEffect';
import { type SingleTabProps } from '@/ui/layout/tab-list/types/SingleTabProps';
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
-import { SidePanelPages } from 'twenty-shared/types';
import { isDefined } from 'twenty-shared/utils';
import { themeCssVariables } from 'twenty-ui/theme-constants';
import {
@@ -50,11 +53,34 @@ import {
PageLayoutType,
} from '~/generated-metadata/graphql';
-const StyledContainer = styled.div`
+const StyledNodeDimension = styled(NodeDimension)`
+ min-width: 0;
+`;
+
+// In the identifier bar the wrapper must fill its grid track so tabs can
+// reappear when the track grows after an overflow. Standalone it sits in a
+// flex column, where growing would eat the tab content's height.
+const identifierBarTrackCssClass = css`
+ flex: 1;
+`;
+
+const StyledContainer = styled.div<{
+ isInIdentifierBar: boolean;
+ centerTabs: boolean;
+}>`
+ ${TAB_LIST_ROW_HEIGHT_CSS_VARIABLE}: ${({ isInIdentifierBar }) =>
+ isInIdentifierBar
+ ? `${PAGE_LAYOUT_RECORD_IDENTIFIER_BAR_HEIGHT}px`
+ : TAB_LIST_HEIGHT};
+
box-sizing: border-box;
display: flex;
- height: ${TAB_LIST_HEIGHT};
+ height: var(${TAB_LIST_ROW_HEIGHT_CSS_VARIABLE});
+ justify-content: ${({ centerTabs }) =>
+ centerTabs ? 'center' : 'flex-start'};
padding-left: ${themeCssVariables.spacing[2]};
+ padding-right: ${({ isInIdentifierBar }) =>
+ isInIdentifierBar ? themeCssVariables.spacing[2] : '0'};
position: relative;
user-select: none;
width: 100%;
@@ -63,6 +89,8 @@ const StyledContainer = styled.div`
background-color: ${themeCssVariables.border.color.light};
bottom: 0;
content: '';
+ display: ${({ isInIdentifierBar }) =>
+ isInIdentifierBar ? 'none' : 'block'};
height: 1px;
left: 0;
position: absolute;
@@ -78,12 +106,13 @@ const StyledDropdownContainer = styled.div`
const StyledAddButton = styled.div`
align-items: center;
display: flex;
- height: ${TAB_LIST_HEIGHT};
+ height: var(${TAB_LIST_ROW_HEIGHT_CSS_VARIABLE}, ${TAB_LIST_HEIGHT});
margin-left: ${TAB_LIST_GAP}px;
`;
type PageLayoutTabListProps = Omit<TabListProps, 'tabs'> & {
tabs: PageLayoutTab[];
+ presentation?: 'standalone' | 'identifier-bar';
isReorderEnabled: boolean;
addTabStrategy?: PageLayoutAddTabStrategy;
behaveAsLinks: boolean;
@@ -96,6 +125,8 @@ export const PageLayoutTabList = ({
behaveAsLinks,
isInSidePanel,
className,
+ presentation = 'standalone',
+ centerTabs = false,
componentInstanceId,
onChangeTab,
addTabStrategy,
@@ -104,6 +135,7 @@ export const PageLayoutTabList = ({
}: PageLayoutTabListProps) => {
const { getIcon } = useIcons();
const { t } = useLingui();
+ const isInIdentifierBar = presentation === 'identifier-bar';
const tabsWithIcons: SingleTabProps[] = tabs.map((tab) => ({
id: tab.id,
@@ -131,6 +163,7 @@ export const PageLayoutTabList = ({
} = useTabListMeasurements({
visibleTabs: tabsWithIcons,
hasAddButton: isDefined(addTabStrategy),
+ rightPadding: isInIdentifierBar ? TAB_LIST_HORIZONTAL_PADDING : 0,
});
const pageLayoutId = useAvailableComponentInstanceIdOrThrow(
@@ -238,22 +271,7 @@ export const PageLayoutTabList = ({
pageLayoutTabSettingsOpenTabIdComponentState,
pageLayoutId,
);
- const setPageLayoutTabSettingsOpenTabId = useSetAtomComponentState(
- pageLayoutTabSettingsOpenTabIdComponentState,
- pageLayoutId,
- );
- const { navigatePageLayoutSidePanel } = useNavigatePageLayoutSidePanel();
-
- const openTabSettings = useCallback(
- (tabId: string) => {
- setPageLayoutTabSettingsOpenTabId(tabId);
- navigatePageLayoutSidePanel({
- sidePanelPage: SidePanelPages.PageLayoutTabSettings,
- resetNavigationStack: true,
- });
- },
- [setPageLayoutTabSettingsOpenTabId, navigatePageLayoutSidePanel],
- );
+ const { openTabSettings } = useOpenPageLayoutTabSettings(pageLayoutId);
const isTabSettingsOpen = isDefined(pageLayoutTabSettingsOpenTabId);
@@ -398,8 +416,15 @@ export const PageLayoutTabList = ({
/>
)}
- <NodeDimension onDimensionChange={handleContainerWidthChange}>
- <StyledContainer className={className}>
+ <StyledNodeDimension
+ className={isInIdentifierBar ? identifierBarTrackCssClass : undefined}
+ onDimensionChange={handleContainerWidthChange}
+ >
+ <StyledContainer
+ className={className}
+ isInIdentifierBar={isInIdentifierBar}
+ centerTabs={centerTabs}
+ >
<PageLayoutTabListVisibleTabs
visibleTabs={tabsWithIcons}
visibleTabCount={
@@ -486,7 +511,7 @@ export const PageLayoutTabList = ({
</StyledAddButton>
)}
</StyledContainer>
- </NodeDimension>
+ </StyledNodeDimension>
</TabListComponentInstanceContext.Provider>
);
};
diff --git a/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabsRenderer.tsx b/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabsRenderer.tsx
index 68845c7ada6..620c1477ca3 100644
--- a/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabsRenderer.tsx
+++ b/packages/twenty-front/src/modules/page-layout/components/PageLayoutTabsRenderer.tsx
@@ -1,6 +1,7 @@
import { PageLayoutWidgetDndProvider } from '@/page-layout/components/dnd/PageLayoutWidgetDndProvider';
import { PageLayoutLeftPanel } from '@/page-layout/components/PageLayoutLeftPanel';
import { PageLayoutPrerenderedTabIdsResetEffect } from '@/page-layout/components/PageLayoutPrerenderedTabIdsResetEffect';
+import { PageLayoutRecordIdentifierBar } from '@/page-layout/components/PageLayoutRecordIdentifierBar';
import { PageLayoutScrollResetEffect } from '@/page-layout/components/PageLayoutScrollResetEffect';
import { PageLayoutTabList } from '@/page-layout/components/PageLayoutTabList';
import { PageLayoutTabListEffect } from '@/page-layout/components/PageLayoutTabListEffect';
@@ -18,18 +19,34 @@ import { shouldPrerenderPageLayoutTab } from '@/page-layout/utils/shouldPrerende
import { sortTabsByPosition } from '@/page-layout/utils/sortTabsByPosition';
import { useLayoutRenderingContext } from '@/ui/layout/contexts/LayoutRenderingContext';
import { activeTabIdComponentState } from '@/ui/layout/tab-list/states/activeTabIdComponentState';
+import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
import { ScrollWrapper } from '@/ui/utilities/scroll/components/ScrollWrapper';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
import { styled } from '@linaria/react';
import { isDefined } from 'twenty-shared/utils';
import { MOBILE_VIEWPORT, themeCssVariables } from 'twenty-ui/theme-constants';
+import { PageLayoutType } from '~/generated-metadata/graphql';
+
+const StyledRoot = styled.div`
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+ min-height: 0;
+ width: 100%;
+
+ @media print {
+ display: block;
+ height: auto;
+ }
+`;
const StyledContainer = styled.div<{ hasPinnedTab: boolean }>`
display: grid;
+ flex: 1;
grid-template-columns: ${({ hasPinnedTab }) =>
hasPinnedTab ? `${PAGE_LAYOUT_LEFT_PANEL_CONTAINER_WIDTH}px 1fr` : '1fr'};
grid-template-rows: minmax(0, 1fr);
- height: 100%;
+ min-height: 0;
width: 100%;
@media print {
@@ -115,6 +132,8 @@ export const PageLayoutTabsRenderer = () => {
const isPageLayoutInEditMode = useIsPageLayoutInEditMode();
+ const isMobile = useIsMobile();
+
const activeTabId = useAtomComponentStateValue(activeTabIdComponentState);
const scrollWrapperInstanceId =
@@ -165,6 +184,29 @@ export const PageLayoutTabsRenderer = () => {
})),
);
+ const shouldRenderRecordIdentifierBar =
+ currentPageLayout.type === PageLayoutType.RECORD_PAGE &&
+ isDefined(targetRecordIdentifier) &&
+ !isInSidePanel &&
+ !isMobile;
+
+ const tabList = (sortedTabs.length > 1 || isPageLayoutInEditMode) && (
+ <PageLayoutTabList
+ className="page-layout-tab-list-print-hidden"
+ presentation={
+ shouldRenderRecordIdentifierBar ? 'identifier-bar' : 'standalone'
+ }
+ centerTabs={shouldRenderRecordIdentifierBar && !isDefined(pinnedLeftTab)}
+ tabs={sortedTabs}
+ behaveAsLinks={!isInSidePanel && !isPageLayoutInEditMode}
+ isInSidePanel={isInSidePanel}
+ componentInstanceId={tabListInstanceId}
+ addTabStrategy={addTabStrategy}
+ isReorderEnabled={canEnableTabEditing}
+ pageLayoutType={currentPageLayout.type}
+ />
+ );
+
return (
<PageLayoutWidgetDndProvider>
<PageLayoutScrollResetEffect
@@ -173,56 +215,56 @@ export const PageLayoutTabsRenderer = () => {
targetRecordId={targetRecordIdentifier?.id}
/>
<PageLayoutPrerenderedTabIdsResetEffect />
- <StyledContainer hasPinnedTab={isDefined(pinnedLeftTab)}>
- {isDefined(pinnedLeftTab) && (
- <PageLayoutLeftPanel
- pageLayoutId={currentPageLayout.id}
- pinnedLeftTabId={pinnedLeftTab.id}
+ <StyledRoot>
+ {shouldRenderRecordIdentifierBar && (
+ <PageLayoutRecordIdentifierBar
+ targetRecordIdentifier={targetRecordIdentifier}
+ pinnedTab={pinnedLeftTab}
+ isPinnedTabEditable={isPageLayoutInEditMode}
+ tabList={tabList}
/>
)}
- <StyledTabsAndDashboardContainer>
- <PageLayoutTabListEffect
- tabs={sortedTabs}
- componentInstanceId={tabListInstanceId}
- defaultTabToFocusOnMobileAndSidePanelId={
- currentPageLayout.defaultTabToFocusOnMobileAndSidePanelId ??
- undefined
- }
- />
- {(sortedTabs.length > 1 || isPageLayoutInEditMode) && (
- <PageLayoutTabList
- className="page-layout-tab-list-print-hidden"
+ <StyledContainer hasPinnedTab={isDefined(pinnedLeftTab)}>
+ {isDefined(pinnedLeftTab) && (
+ <PageLayoutLeftPanel
+ pageLayoutId={currentPageLayout.id}
+ pinnedLeftTabId={pinnedLeftTab.id}
+ />
+ )}
+
+ <StyledTabsAndDashboardContainer>
+ <PageLayoutTabListEffect
tabs={sortedTabs}
- behaveAsLinks={!isInSidePanel && !isPageLayoutInEditMode}
- isInSidePanel={isInSidePanel}
componentInstanceId={tabListInstanceId}
- addTabStrategy={addTabStrategy}
- isReorderEnabled={canEnableTabEditing}
- pageLayoutType={currentPageLayout.type}
+ defaultTabToFocusOnMobileAndSidePanelId={
+ currentPageLayout.defaultTabToFocusOnMobileAndSidePanelId ??
+ undefined
+ }
/>
- )}
+ {!shouldRenderRecordIdentifierBar && tabList}
- <StyledScrollWrapperContainer>
- <ScrollWrapper
- className="page-layout-scroll-wrapper"
- componentInstanceId={scrollWrapperInstanceId}
- defaultEnableXScroll={false}
- >
- {isDefined(activeTabId) &&
- activeTabExistsInRenderableTabs &&
- tabsToMount.map((tab) => (
- <StyledTabContentDisplay
- key={tab.id}
- isActiveTab={tab.id === activeTabId}
- >
- <PageLayoutMainContent tabId={tab.id} />
- </StyledTabContentDisplay>
- ))}
- </ScrollWrapper>
- </StyledScrollWrapperContainer>
- </StyledTabsAndDashboardContainer>
- </StyledContainer>
+ <StyledScrollWrapperContainer>
+ <ScrollWrapper
+ className="page-layout-scroll-wrapper"
+ componentInstanceId={scrollWrapperInstanceId}
+ defaultEnableXScroll={false}
+ >
+ {isDefined(activeTabId) &&
+ activeTabExistsInRenderableTabs &&
+ tabsToMount.map((tab) => (
+ <StyledTabContentDisplay
+ key={tab.id}
+ isActiveTab={tab.id === activeTabId}
+ >
+ <PageLayoutMainContent tabId={tab.id} />
+ </StyledTabContentDisplay>
+ ))}
+ </ScrollWrapper>
+ </StyledScrollWrapperContainer>
+ </StyledTabsAndDashboardContainer>
+ </StyledContainer>
+ </StyledRoot>
</PageLayoutWidgetDndProvider>
);
};
diff --git a/packages/twenty-front/src/modules/page-layout/components/PageLayoutVerticalList.tsx b/packages/twenty-front/src/modules/page-layout/components/PageLayoutVerticalList.tsx
index 4f5c17f0d2f..91097eb7455 100644
--- a/packages/twenty-front/src/modules/page-layout/components/PageLayoutVerticalList.tsx
+++ b/packages/twenty-front/src/modules/page-layout/components/PageLayoutVerticalList.tsx
@@ -17,6 +17,7 @@ import { PageLayoutTabLayoutMode } from '~/generated-metadata/graphql';
const StyledVerticalListContainer = styled.div<{
isInEditMode: boolean;
+ isInPinnedTab: boolean;
isSideColumnContext: boolean;
shouldUseWhiteBackground: boolean;
}>`
@@ -43,11 +44,17 @@ const StyledVerticalListContainer = styled.div<{
gap: ${({ isInEditMode }) =>
isInEditMode ? themeCssVariables.spacing[4] : '0'};
min-height: ${({ isInEditMode }) => (isInEditMode ? '0' : '100%')};
- padding: ${({ isInEditMode, isSideColumnContext }) =>
+ // The pinned tab sits next to the main tab area, so while editing it takes
+ // that area's vertical padding to line their widgets up, and keeps the
+ // tighter side-column one horizontally where the narrow column needs the
+ // room.
+ padding: ${({ isInEditMode, isInPinnedTab, isSideColumnContext }) =>
isInEditMode
- ? isSideColumnContext
- ? themeCssVariables.spacing[1]
- : themeCssVariables.spacing[2]
+ ? isInPinnedTab
+ ? `${themeCssVariables.spacing[2]} ${themeCssVariables.spacing[1]}`
+ : isSideColumnContext
+ ? themeCssVariables.spacing[1]
+ : themeCssVariables.spacing[2]
: '0'};
`;
@@ -118,6 +125,7 @@ export const PageLayoutVerticalList = ({
return (
<StyledVerticalListContainer
isInEditMode={isInEditMode}
+ isInPinnedTab={isInPinnedTab}
isSideColumnContext={isSideColumnContext}
shouldUseWhiteBackground={!isInPinnedTab || isMobile}
>
diff --git a/packages/twenty-front/src/modules/page-layout/components/__stories__/PageLayoutTabList.stories.tsx b/packages/twenty-front/src/modules/page-layout/components/__stories__/PageLayoutTabList.stories.tsx
index 22db1b127c8..3a32da53e84 100644
--- a/packages/twenty-front/src/modules/page-layout/components/__stories__/PageLayoutTabList.stories.tsx
+++ b/packages/twenty-front/src/modules/page-layout/components/__stories__/PageLayoutTabList.stories.tsx
@@ -1,23 +1,40 @@
import { styled } from '@linaria/react';
import type { Meta, StoryObj } from '@storybook/react-vite';
-import { useEffect, useMemo } from 'react';
+import { type ComponentProps, useEffect, useMemo } from 'react';
+import { expect, userEvent, waitFor, within } from 'storybook/test';
import { ComponentWithRouterDecorator } from 'twenty-ui/testing';
import { PageLayoutTabList } from '@/page-layout/components/PageLayoutTabList';
import { PageLayoutTabListEffect } from '@/page-layout/components/PageLayoutTabListEffect';
import { PageLayoutWidgetDndProvider } from '@/page-layout/components/dnd/PageLayoutWidgetDndProvider';
+import { PAGE_LAYOUT_RECORD_IDENTIFIER_BAR_HEIGHT } from '@/page-layout/constants/PageLayoutRecordIdentifierBarHeight';
import { PageLayoutEditModeProviderContext } from '@/page-layout/contexts/PageLayoutEditModeContext';
import { PageLayoutComponentInstanceContext } from '@/page-layout/states/contexts/PageLayoutComponentInstanceContext';
import { pageLayoutDraftComponentState } from '@/page-layout/states/pageLayoutDraftComponentState';
import { type PageLayoutTab } from '@/page-layout/types/PageLayoutTab';
+import { LayoutRenderingProvider } from '@/ui/layout/contexts/LayoutRenderingContext';
+import { activeTabIdComponentState } from '@/ui/layout/tab-list/states/activeTabIdComponentState';
+import { jotaiStore } from '@/ui/utilities/state/jotai/jotaiStore';
import { useAtomComponentState } from '@/ui/utilities/state/jotai/hooks/useAtomComponentState';
import { themeCssVariables } from 'twenty-ui/theme-constants';
import { PageLayoutType } from '~/generated-metadata/graphql';
-const StyledContainer = styled.div`
+const StyledContainer = styled.div<{ containerWidth: number }>`
border: 1px solid ${themeCssVariables.border.color.strong};
padding: ${themeCssVariables.spacing[4]};
- width: 720px;
+ width: ${({ containerWidth }) => containerWidth}px;
+`;
+
+const StyledTabListContainer = styled.div<{ isInIdentifierBar: boolean }>`
+ box-shadow: ${({ isInIdentifierBar }) =>
+ isInIdentifierBar
+ ? `inset 0 -1px 0 ${themeCssVariables.border.color.light}`
+ : 'none'};
+ display: ${({ isInIdentifierBar }) => (isInIdentifierBar ? 'flex' : 'block')};
+ height: ${({ isInIdentifierBar }) =>
+ isInIdentifierBar
+ ? `${PAGE_LAYOUT_RECORD_IDENTIFIER_BAR_HEIGHT}px`
+ : 'auto'};
`;
const createInitialTabs = (): PageLayoutTab[] => [
@@ -69,11 +86,20 @@ const createInitialTabs = (): PageLayoutTab[] => [
},
];
+type PageLayoutTabListPlaygroundProps = Pick<
+ ComponentProps<typeof PageLayoutTabList>,
+ 'isReorderEnabled' | 'presentation' | 'centerTabs'
+> & {
+ containerWidth?: number;
+};
+
const PageLayoutTabListPlayground = ({
isReorderEnabled,
-}: {
- isReorderEnabled: boolean;
-}) => {
+ presentation = 'standalone',
+ centerTabs = false,
+ containerWidth = 720,
+}: PageLayoutTabListPlaygroundProps) => {
+ const isInIdentifierBar = presentation === 'identifier-bar';
// Tab drops are routed into the page-layout draft by the dnd provider, so
// the story renders from that draft to stay interactive.
const [pageLayoutDraft, setPageLayoutDraft] = useAtomComponentState(
@@ -119,26 +145,34 @@ const PageLayoutTabListPlayground = ({
};
return (
- <StyledContainer>
+ <StyledContainer containerWidth={containerWidth}>
<PageLayoutTabListEffect
tabs={sortedTabs}
componentInstanceId="page-layout-tab-list-story"
/>
<PageLayoutWidgetDndProvider>
- <PageLayoutTabList
- tabs={sortedTabs}
- componentInstanceId="page-layout-tab-list-story"
- behaveAsLinks={false}
- loading={false}
- addTabStrategy={
- isReorderEnabled
- ? { mode: 'direct', onCreate: handleAddTab }
- : undefined
- }
- isReorderEnabled={isReorderEnabled}
- pageLayoutType={PageLayoutType.DASHBOARD}
- />
+ <StyledTabListContainer isInIdentifierBar={isInIdentifierBar}>
+ <PageLayoutTabList
+ tabs={sortedTabs}
+ componentInstanceId="page-layout-tab-list-story"
+ behaveAsLinks={false}
+ loading={false}
+ addTabStrategy={
+ isReorderEnabled
+ ? { mode: 'direct', onCreate: handleAddTab }
+ : undefined
+ }
+ isReorderEnabled={isReorderEnabled}
+ pageLayoutType={
+ isInIdentifierBar
+ ? PageLayoutType.RECORD_PAGE
+ : PageLayoutType.DASHBOARD
+ }
+ presentation={presentation}
+ centerTabs={centerTabs}
+ />
+ </StyledTabListContainer>
</PageLayoutWidgetDndProvider>
</StyledContainer>
);
@@ -152,12 +186,23 @@ const meta: Meta<typeof PageLayoutTabListPlayground> = {
},
decorators: [
ComponentWithRouterDecorator,
- (Story) => (
+ (Story, { args }) => (
<PageLayoutEditModeProviderContext value={{ isInEditMode: false }}>
<PageLayoutComponentInstanceContext.Provider
value={{ instanceId: 'instance-id' }}
>
- <Story />
+ <LayoutRenderingProvider
+ value={{
+ isInSidePanel: false,
+ layoutType:
+ args.presentation === 'identifier-bar'
+ ? PageLayoutType.RECORD_PAGE
+ : PageLayoutType.DASHBOARD,
+ targetRecordIdentifier: undefined,
+ }}
+ >
+ <Story />
+ </LayoutRenderingProvider>
</PageLayoutComponentInstanceContext.Provider>
</PageLayoutEditModeProviderContext>
),
@@ -172,4 +217,81 @@ export const Default: Story = {
args: {
isReorderEnabled: true,
},
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ expect(
+ await canvas.findByRole('button', { name: 'Overview' }),
+ ).toBeVisible();
+ expect(canvas.getByRole('button', { name: 'Forecasts' })).toBeVisible();
+
+ await userEvent.click(
+ within(canvas.getByRole('button', { name: 'Revenue' })).getByText(
+ 'Revenue',
+ ),
+ );
+
+ await waitFor(() =>
+ expect(
+ jotaiStore.get(
+ activeTabIdComponentState.atomFamily({
+ instanceId: 'page-layout-tab-list-story',
+ }),
+ ),
+ ).toBe('revenue'),
+ );
+ },
+};
+
+export const IdentifierBar: Story = {
+ args: {
+ presentation: 'identifier-bar',
+ isReorderEnabled: false,
+ },
+ play: Default.play,
+};
+
+export const IdentifierBarCentered: Story = {
+ args: {
+ ...IdentifierBar.args,
+ centerTabs: true,
+ },
+ play: Default.play,
+};
+
+export const IdentifierBarNarrow: Story = {
+ args: {
+ presentation: 'identifier-bar',
+ containerWidth: 240,
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const body = within(canvasElement.ownerDocument.body);
+
+ const [moreButton] = await canvas.findAllByRole('button', { name: /More/ });
+
+ await userEvent.click(moreButton);
+ await userEvent.click(await body.findByRole('option', { name: 'Revenue' }));
+ await userEvent.click(moreButton);
+
+ expect(
+ await body.findByRole('option', { name: 'Revenue' }),
+ ).toHaveAttribute('aria-selected', 'true');
+
+ await userEvent.click(body.getByRole('option', { name: 'Revenue' }));
+ await userEvent.click(canvas.getByRole('button', { name: 'New Tab' }));
+ await userEvent.click(moreButton);
+
+ expect(
+ await body.findByRole('option', { name: 'New Tab 3' }),
+ ).toBeVisible();
+ },
+};
+
+export const IdentifierBarCenteredNarrow: Story = {
+ args: {
+ ...IdentifierBarNarrow.args,
+ centerTabs: true,
+ },
+ play: IdentifierBarNarrow.play,
};
diff --git a/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutLeftPanel.test.tsx b/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutLeftPanel.test.tsx
index 8edc9a26f83..b4e39a32ebe 100644
--- a/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutLeftPanel.test.tsx
+++ b/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutLeftPanel.test.tsx
@@ -9,10 +9,6 @@ let mockTargetRecordIdentifier = {
};
let mockIsInSidePanel = false;
-jest.mock('@/object-record/record-show/components/SummaryCard', () => ({
- SummaryCard: () => null,
-}));
-
jest.mock('@/page-layout/components/PageLayoutContent', () => ({
PageLayoutContent: () => <div>Page layout content</div>,
}));
diff --git a/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutRecordIdentifierBar.test.tsx b/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutRecordIdentifierBar.test.tsx
new file mode 100644
index 00000000000..04aa1404ba3
--- /dev/null
+++ b/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutRecordIdentifierBar.test.tsx
@@ -0,0 +1,182 @@
+import { PageLayoutRecordIdentifierBar } from '@/page-layout/components/PageLayoutRecordIdentifierBar';
+import { i18n } from '@lingui/core';
+import { I18nProvider } from '@lingui/react';
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { type ReactNode } from 'react';
+
+const TARGET_RECORD_IDENTIFIER = {
+ id: 'company-id',
+ targetObjectNameSingular: 'company',
+};
+
+const PINNED_TAB = { id: 'pinned-tab-id', title: 'Tasks' };
+
+let mockRecordCreatedAt: string | null = '2026-08-25T12:00:00.000Z';
+const mockOpenTabSettings = jest.fn();
+
+jest.mock(
+ '@/object-record/record-show/components/RecordIdentifierBarTitle',
+ () => ({
+ RecordIdentifierBarTitle: () => <div>Google</div>,
+ }),
+);
+
+jest.mock('@/page-layout/hooks/useOpenPageLayoutTabSettings', () => ({
+ useOpenPageLayoutTabSettings: () => ({
+ openTabSettings: mockOpenTabSettings,
+ }),
+}));
+
+jest.mock(
+ '@/ui/utilities/state/jotai/hooks/useAtomFamilySelectorValue',
+ () => ({
+ useAtomFamilySelectorValue: () => mockRecordCreatedAt,
+ }),
+);
+
+const Wrapper = ({ children }: { children: ReactNode }) => (
+ <I18nProvider i18n={i18n}>{children}</I18nProvider>
+);
+
+describe('PageLayoutRecordIdentifierBar', () => {
+ beforeEach(() => {
+ jest.useFakeTimers();
+ jest.setSystemTime(new Date('2026-08-27T12:00:00.000Z'));
+ mockRecordCreatedAt = '2026-08-25T12:00:00.000Z';
+ mockOpenTabSettings.mockClear();
+ });
+
+ afterEach(() => {
+ jest.useRealTimers();
+ });
+
+ it('moves the creation date after the tabs only when no tab is pinned', () => {
+ const { rerender } = render(
+ <PageLayoutRecordIdentifierBar
+ targetRecordIdentifier={TARGET_RECORD_IDENTIFIER}
+ pinnedTab={PINNED_TAB}
+ tabList={<div>Home</div>}
+ />,
+ { wrapper: Wrapper },
+ );
+
+ expect(screen.getByText('Google').parentElement).toContainElement(
+ screen.getByText('Created 2 days ago'),
+ );
+ expect(screen.getByText('Home')).toBeVisible();
+
+ rerender(
+ <PageLayoutRecordIdentifierBar
+ targetRecordIdentifier={TARGET_RECORD_IDENTIFIER}
+ tabList={<div>Home</div>}
+ />,
+ );
+
+ const createdAt = screen.getByText('Created 2 days ago');
+
+ expect(screen.getByText('Google').parentElement).not.toContainElement(
+ createdAt,
+ );
+ expect(screen.getByText('Home').compareDocumentPosition(createdAt)).toBe(
+ Node.DOCUMENT_POSITION_FOLLOWING,
+ );
+ });
+
+ it('keeps the pinned tab settings accessible beside the creation date', async () => {
+ const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
+
+ const { rerender } = render(
+ <PageLayoutRecordIdentifierBar
+ targetRecordIdentifier={TARGET_RECORD_IDENTIFIER}
+ pinnedTab={PINNED_TAB}
+ isPinnedTabEditable
+ />,
+ { wrapper: Wrapper },
+ );
+
+ expect(screen.getByText('Google').parentElement).toContainElement(
+ screen.getByText('Created 2 days ago'),
+ );
+
+ expect(screen.queryByText('Tasks')).not.toBeInTheDocument();
+
+ await user.click(
+ screen.getByRole('button', { name: 'Edit pinned tab: Tasks' }),
+ );
+
+ expect(mockOpenTabSettings).toHaveBeenCalledTimes(1);
+ expect(mockOpenTabSettings).toHaveBeenCalledWith('pinned-tab-id');
+
+ rerender(
+ <PageLayoutRecordIdentifierBar
+ targetRecordIdentifier={TARGET_RECORD_IDENTIFIER}
+ pinnedTab={PINNED_TAB}
+ isPinnedTabEditable={false}
+ />,
+ );
+
+ expect(
+ screen.queryByRole('button', { name: 'Edit pinned tab: Tasks' }),
+ ).not.toBeInTheDocument();
+ expect(screen.getByText('Google').parentElement).toContainElement(
+ screen.getByText('Created 2 days ago'),
+ );
+ });
+
+ it('does not show pinned tab settings outside edit mode', () => {
+ render(
+ <PageLayoutRecordIdentifierBar
+ targetRecordIdentifier={TARGET_RECORD_IDENTIFIER}
+ pinnedTab={PINNED_TAB}
+ />,
+ { wrapper: Wrapper },
+ );
+
+ expect(
+ screen.queryByRole('button', { name: 'Edit pinned tab: Tasks' }),
+ ).not.toBeInTheDocument();
+ });
+
+ it('does not show pinned tab settings when no tab is pinned', () => {
+ const { rerender } = render(
+ <PageLayoutRecordIdentifierBar
+ targetRecordIdentifier={TARGET_RECORD_IDENTIFIER}
+ pinnedTab={PINNED_TAB}
+ isPinnedTabEditable
+ />,
+ { wrapper: Wrapper },
+ );
+
+ expect(
+ screen.getByRole('button', { name: 'Edit pinned tab: Tasks' }),
+ ).toBeVisible();
+
+ rerender(
+ <PageLayoutRecordIdentifierBar
+ targetRecordIdentifier={TARGET_RECORD_IDENTIFIER}
+ isPinnedTabEditable
+ />,
+ );
+
+ expect(
+ screen.queryByRole('button', { name: 'Edit pinned tab: Tasks' }),
+ ).not.toBeInTheDocument();
+ expect(screen.getByText('Created 2 days ago')).toBeVisible();
+ });
+
+ it('renders the record header without a creation date', () => {
+ mockRecordCreatedAt = null;
+
+ render(
+ <PageLayoutRecordIdentifierBar
+ targetRecordIdentifier={TARGET_RECORD_IDENTIFIER}
+ pinnedTab={PINNED_TAB}
+ />,
+ { wrapper: Wrapper },
+ );
+
+ expect(screen.getByText('Google')).toBeVisible();
+ expect(screen.queryByText(/^Created /)).not.toBeInTheDocument();
+ });
+});
diff --git a/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutSingleTabRenderer.test.tsx b/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutSingleTabRenderer.test.tsx
new file mode 100644
index 00000000000..7a538bec6a4
--- /dev/null
+++ b/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutSingleTabRenderer.test.tsx
@@ -0,0 +1,151 @@
+import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
+import { PageLayoutSingleTabRenderer } from '@/page-layout/components/PageLayoutSingleTabRenderer';
+import { usePageLayoutContentContext } from '@/page-layout/contexts/PageLayoutContentContext';
+import { pageLayoutIsInitializedComponentState } from '@/page-layout/states/pageLayoutIsInitializedComponentState';
+import { pageLayoutPersistedComponentState } from '@/page-layout/states/pageLayoutPersistedComponentState';
+import { makeTab } from '@/page-layout/testing/pageLayoutDraftFixtures';
+import { type PageLayout } from '@/page-layout/types/PageLayout';
+import { LayoutRenderingProvider } from '@/ui/layout/contexts/LayoutRenderingContext';
+import { i18n } from '@lingui/core';
+import { I18nProvider } from '@lingui/react';
+import { render, screen } from '@testing-library/react';
+import { createStore, Provider as JotaiProvider } from 'jotai';
+import { type ReactNode } from 'react';
+import { PageLayoutType } from '~/generated-metadata/graphql';
+
+const PAGE_LAYOUT_ID = 'page-layout-id';
+
+jest.mock(
+ '@/object-record/record-show/components/RecordIdentifierBarTitle',
+ () => ({
+ RecordIdentifierBarTitle: ({
+ objectNameSingular,
+ objectRecordId,
+ }: {
+ objectNameSingular: string;
+ objectRecordId: string;
+ }) => <div>{`${objectNameSingular}: ${objectRecordId}`}</div>,
+ }),
+);
+
+jest.mock(
+ '@/page-layout/components/PageLayoutInitializationQueryEffect',
+ () => ({
+ PageLayoutInitializationQueryEffect: () => null,
+ }),
+);
+
+jest.mock(
+ '@/page-layout/components/PageLayoutRecordPageCustomizationSessionRegistrationEffect',
+ () => ({
+ PageLayoutRecordPageCustomizationSessionRegistrationEffect: () => null,
+ }),
+);
+
+jest.mock(
+ '@/page-layout/widgets/record-table/components/RecordTableWidgetViewDraftsInitializationEffect',
+ () => ({
+ RecordTableWidgetViewDraftsInitializationEffect: () => null,
+ }),
+);
+
+jest.mock('@/page-layout/components/dnd/PageLayoutWidgetDndProvider', () => ({
+ PageLayoutWidgetDndProvider: ({ children }: { children: ReactNode }) => (
+ <>{children}</>
+ ),
+}));
+
+jest.mock('@/page-layout/components/PageLayoutContent', () => ({
+ PageLayoutContent: () => {
+ const { tabId } = usePageLayoutContentContext();
+
+ return <div>Rendered tab: {tabId}</div>;
+ },
+}));
+
+describe('PageLayoutSingleTabRenderer', () => {
+ beforeEach(() => {
+ jest.useFakeTimers();
+ jest.setSystemTime(new Date('2026-08-27T12:00:00.000Z'));
+ });
+
+ afterEach(() => {
+ jest.useRealTimers();
+ });
+
+ it('updates the identifier title and creation date when switching between merge records', () => {
+ const store = createStore();
+
+ store.set(recordStoreFamilyState.atomFamily('source-record'), {
+ __typename: 'Company',
+ id: 'source-record',
+ createdAt: '2026-08-25T12:00:00.000Z',
+ });
+ store.set(recordStoreFamilyState.atomFamily('merge-preview'), {
+ __typename: 'Company',
+ id: 'merge-preview',
+ createdAt: '2026-08-26T12:00:00.000Z',
+ });
+
+ store.set(
+ pageLayoutPersistedComponentState.atomFamily({
+ instanceId: PAGE_LAYOUT_ID,
+ }),
+ {
+ id: PAGE_LAYOUT_ID,
+ name: 'Record Page',
+ type: PageLayoutType.RECORD_PAGE,
+ tabs: [makeTab('fields-tab', [])],
+ } as PageLayout,
+ );
+ store.set(
+ pageLayoutIsInitializedComponentState.atomFamily({
+ instanceId: PAGE_LAYOUT_ID,
+ }),
+ true,
+ );
+
+ const renderForRecord = (recordId: string) => (
+ <JotaiProvider store={store}>
+ <LayoutRenderingProvider
+ value={{
+ targetRecordIdentifier: {
+ id: recordId,
+ targetObjectNameSingular: 'company',
+ },
+ layoutType: PageLayoutType.RECORD_PAGE,
+ isInSidePanel: true,
+ }}
+ >
+ <I18nProvider i18n={i18n}>
+ <PageLayoutSingleTabRenderer pageLayoutId={PAGE_LAYOUT_ID} />
+ </I18nProvider>
+ </LayoutRenderingProvider>
+ </JotaiProvider>
+ );
+
+ const { rerender } = render(renderForRecord('source-record'));
+
+ expect(screen.getByText('company: source-record')).toBeVisible();
+ expect(screen.getByText('Created 2 days ago')).toBeVisible();
+ expect(screen.getByText('Rendered tab: fields-tab')).toBeVisible();
+
+ rerender(renderForRecord('merge-preview'));
+
+ expect(
+ screen.queryByText('company: source-record'),
+ ).not.toBeInTheDocument();
+ expect(screen.getByText('company: merge-preview')).toBeVisible();
+ expect(screen.getByText('Created 1 day ago')).toBeVisible();
+ expect(screen.queryByText('Created 2 days ago')).not.toBeInTheDocument();
+ expect(screen.getByText('Rendered tab: fields-tab')).toBeVisible();
+
+ rerender(renderForRecord('preview-without-created-at'));
+
+ expect(
+ screen.getByText('company: preview-without-created-at'),
+ ).toBeVisible();
+ expect(screen.queryByText(/^Created /)).not.toBeInTheDocument();
+ expect(screen.getByText('Rendered tab: fields-tab')).toBeVisible();
+ });
+});
diff --git a/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabsRenderer.test.tsx b/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabsRenderer.test.tsx
index 350da8f4bd6..9ed8bc19e4c 100644
--- a/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabsRenderer.test.tsx
+++ b/packages/twenty-front/src/modules/page-layout/components/__tests__/PageLayoutTabsRenderer.test.tsx
@@ -57,6 +57,10 @@ jest.mock('@/page-layout/components/PageLayoutLeftPanel', () => ({
PageLayoutLeftPanel: () => null,
}));
+jest.mock('@/page-layout/components/PageLayoutRecordIdentifierBar', () => ({
+ PageLayoutRecordIdentifierBar: () => null,
+}));
+
jest.mock('@/page-layout/components/PageLayoutTabList', () => ({
PageLayoutTabList: () => null,
}));
diff --git a/packages/twenty-front/src/modules/page-layout/constants/PageLayoutRecordIdentifierBarHeight.ts b/packages/twenty-front/src/modules/page-layout/constants/PageLayoutRecordIdentifierBarHeight.ts
new file mode 100644
index 00000000000..46d09f6f238
--- /dev/null
+++ b/packages/twenty-front/src/modules/page-layout/constants/PageLayoutRecordIdentifierBarHeight.ts
@@ -0,0 +1 @@
+export const PAGE_LAYOUT_RECORD_IDENTIFIER_BAR_HEIGHT = 48;
diff --git a/packages/twenty-front/src/modules/page-layout/hooks/useOpenPageLayoutTabSettings.ts b/packages/twenty-front/src/modules/page-layout/hooks/useOpenPageLayoutTabSettings.ts
new file mode 100644
index 00000000000..17095d58250
--- /dev/null
+++ b/packages/twenty-front/src/modules/page-layout/hooks/useOpenPageLayoutTabSettings.ts
@@ -0,0 +1,29 @@
+import { pageLayoutTabSettingsOpenTabIdComponentState } from '@/page-layout/states/pageLayoutTabSettingsOpenTabIdComponentState';
+import { useNavigatePageLayoutSidePanel } from '@/side-panel/pages/page-layout/hooks/useNavigatePageLayoutSidePanel';
+import { useSetAtomComponentState } from '@/ui/utilities/state/jotai/hooks/useSetAtomComponentState';
+import { useCallback } from 'react';
+import { SidePanelPages } from 'twenty-shared/types';
+
+export const useOpenPageLayoutTabSettings = (
+ pageLayoutIdFromProps?: string,
+) => {
+ const setPageLayoutTabSettingsOpenTabId = useSetAtomComponentState(
+ pageLayoutTabSettingsOpenTabIdComponentState,
+ pageLayoutIdFromProps,
+ );
+
+ const { navigatePageLayoutSidePanel } = useNavigatePageLayoutSidePanel();
+
+ const openTabSettings = useCallback(
+ (tabId: string) => {
+ setPageLayoutTabSettingsOpenTabId(tabId);
+ navigatePageLayoutSidePanel({
+ sidePanelPage: SidePanelPages.PageLayoutTabSettings,
+ resetNavigationStack: true,
+ });
+ },
+ [setPageLayoutTabSettingsOpenTabId, navigatePageLayoutSidePanel],
+ );
+
+ return { openTabSettings };
+};
diff --git a/packages/twenty-front/src/modules/side-panel/components/SidePanelRecordInfo.tsx b/packages/twenty-front/src/modules/side-panel/components/SidePanelRecordInfo.tsx
index 37363b9da7d..67356e1e9e2 100644
--- a/packages/twenty-front/src/modules/side-panel/components/SidePanelRecordInfo.tsx
+++ b/packages/twenty-front/src/modules/side-panel/components/SidePanelRecordInfo.tsx
@@ -40,6 +40,7 @@ export const SidePanelRecordInfo = ({
<RecordIdentifierBarTitle
objectNameSingular={objectNameSingular}
objectRecordId={objectRecordId}
+ variant="side-panel"
/>
<RecordIdentifierBarCreatedAt objectRecordId={objectRecordId} />
</StyledRecordInfo>
diff --git a/packages/twenty-front/src/modules/ui/layout/page/components/HeaderIdentifier.tsx b/packages/twenty-front/src/modules/ui/layout/page/components/HeaderIdentifier.tsx
index cf2ac6b2109..4239971d76a 100644
--- a/packages/twenty-front/src/modules/ui/layout/page/components/HeaderIdentifier.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/page/components/HeaderIdentifier.tsx
@@ -40,9 +40,9 @@ const StyledTextContainer = styled.div`
min-width: 0;
`;
-const StyledTitle = styled.h3`
+const StyledTitle = styled.h3<{ fontSize: 'md' | 'lg' }>`
color: ${themeCssVariables.font.color.primary};
- font-size: ${themeCssVariables.font.size.md};
+ font-size: ${({ fontSize }) => themeCssVariables.font.size[fontSize]};
font-weight: ${themeCssVariables.font.weight.semiBold};
margin: 0;
min-width: 0;
@@ -56,6 +56,7 @@ type HeaderIdentifierProps = {
>;
icon?: ReactNode;
iconColor?: string;
+ fontSize?: 'md' | 'lg';
title: ReactNode;
label?: ReactNode;
};
@@ -64,6 +65,7 @@ export const HeaderIdentifier = ({
avatar,
icon,
iconColor,
+ fontSize = 'md',
title,
label,
}: HeaderIdentifierProps) => {
@@ -74,19 +76,24 @@ export const HeaderIdentifier = ({
placeholder={avatar.placeholder}
placeholderColorSeed={avatar.placeholderColorSeed}
type={avatar.type}
- size="md"
+ size={fontSize}
/>
) : (
icon
);
+ const shouldRenderInTile = !isDefined(avatar) || fontSize === 'md';
+
return (
<StyledContainer>
- {isDefined(identifierIcon) && (
- <StyledIcon iconColor={iconColor}>{identifierIcon}</StyledIcon>
- )}
+ {isDefined(identifierIcon) &&
+ (shouldRenderInTile ? (
+ <StyledIcon iconColor={iconColor}>{identifierIcon}</StyledIcon>
+ ) : (
+ identifierIcon
+ ))}
<StyledTextContainer>
- <StyledTitle>
+ <StyledTitle fontSize={fontSize}>
{typeof title === 'string' ? (
<OverflowingTextWithTooltip text={title} />
) : (
diff --git a/packages/twenty-front/src/modules/ui/layout/page/components/__stories__/HeaderIdentifier.stories.tsx b/packages/twenty-front/src/modules/ui/layout/page/components/__stories__/HeaderIdentifier.stories.tsx
index 59b34e0b31f..3d139a4bb18 100644
--- a/packages/twenty-front/src/modules/ui/layout/page/components/__stories__/HeaderIdentifier.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/page/components/__stories__/HeaderIdentifier.stories.tsx
@@ -51,6 +51,14 @@ export const Record: Story = {
},
};
+export const RecordPage: Story = {
+ args: {
+ ...Record.args,
+ fontSize: 'lg',
+ },
+ play: Record.play,
+};
+
export const Chart: Story = {
args: {
icon: <IconChartBar size={16} />,
diff --git a/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageSummaryCard.tsx b/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageSummaryCard.tsx
deleted file mode 100644
index 814996d02e0..00000000000
--- a/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageSummaryCard.tsx
+++ /dev/null
@@ -1,190 +0,0 @@
-import { SKELETON_LOADER_HEIGHT_SIZES } from '@/activities/components/SkeletonLoader';
-import { styled } from '@linaria/react';
-import { Trans } from '@lingui/react/macro';
-import {
- type ChangeEvent,
- type ReactNode,
- useContext,
- useId,
- useRef,
-} from 'react';
-import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';
-import { isDefined } from 'twenty-shared/utils';
-import { Avatar, type AvatarType } from 'twenty-ui/data-display';
-import { type IconComponent } from 'twenty-ui/icon';
-import { AppTooltip } from 'twenty-ui/surfaces';
-import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
-import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants';
-import { dateLocaleState } from '~/localization/states/dateLocaleState';
-import {
- beautifyExactDateTime,
- beautifyPastDateRelativeToNow,
-} from '~/utils/date-utils';
-import { getAbsoluteImageUrl } from '~/utils/image/getAbsoluteImageUrl';
-
-type ShowPageSummaryCardProps = {
- avatarPlaceholder: string;
- avatarType: AvatarType;
- date: string;
- id?: string;
- logoOrAvatar?: string;
- icon?: IconComponent;
- iconColor?: string;
- onUploadPicture?: (file: File) => void;
- title: ReactNode;
- loading: boolean;
- isMobile?: boolean;
-};
-
-export const StyledShowPageSummaryCard = styled.div<{
- isMobile: boolean;
-}>`
- align-items: center;
- border-bottom: 1px solid ${themeCssVariables.border.color.light};
- box-sizing: border-box;
- display: flex;
- flex-direction: ${({ isMobile }) => (isMobile ? 'row' : 'column')};
- gap: ${({ isMobile }) =>
- isMobile ? themeCssVariables.spacing[2] : themeCssVariables.spacing[3]};
- height: ${({ isMobile }) => (isMobile ? '77px' : '127px')};
- justify-content: ${({ isMobile }) => (isMobile ? 'flex-start' : 'center')};
- padding: ${themeCssVariables.spacing[4]};
-`;
-
-const StyledInfoContainer = styled.div<{ isMobile: boolean }>`
- align-items: ${({ isMobile }) => (isMobile ? 'flex-start' : 'center')};
- display: flex;
- flex-direction: column;
- gap: ${themeCssVariables.spacing[1]};
- width: 100%;
-`;
-
-const StyledDate = styled.div<{ isMobile: boolean }>`
- color: ${themeCssVariables.font.color.tertiary};
- cursor: pointer;
- padding-left: ${themeCssVariables.spacing[1]};
-`;
-
-const StyledTitle = styled.div<{ isMobile: boolean }>`
- color: ${themeCssVariables.font.color.primary};
- display: flex;
- font-size: ${themeCssVariables.font.size.xl};
- font-weight: ${themeCssVariables.font.weight.semiBold};
- justify-content: ${({ isMobile }) => (isMobile ? 'flex-start' : 'center')};
- width: 90%;
-`;
-
-const StyledAvatarWrapper = styled.div<{
- isAvatarEditable: boolean;
- hasIcon: boolean;
-}>`
- background-color: ${({ hasIcon }) =>
- hasIcon ? themeCssVariables.background.transparent.light : 'unset'};
- border-radius: ${themeCssVariables.border.radius.md};
- cursor: ${({ isAvatarEditable }) =>
- isAvatarEditable ? 'pointer' : 'default'};
-`;
-
-const StyledFileInput = styled.input`
- display: none;
-`;
-
-const StyledSubSkeleton = styled.div`
- align-items: center;
- display: flex;
- height: 37px;
- justify-content: center;
- width: 108px;
-`;
-
-const StyledShowPageSummaryCardSkeletonLoader = () => {
- const { theme } = useContext(ThemeContext);
- return (
- <SkeletonTheme
- baseColor={theme.background.tertiary}
- highlightColor={theme.background.transparent.lighter}
- borderRadius={4}
- >
- <Skeleton width={40} height={SKELETON_LOADER_HEIGHT_SIZES.standard.xl} />
- <StyledSubSkeleton>
- <Skeleton width={96} height={SKELETON_LOADER_HEIGHT_SIZES.standard.s} />
- </StyledSubSkeleton>
- </SkeletonTheme>
- );
-};
-
-export const ShowPageSummaryCard = ({
- avatarPlaceholder,
- avatarType,
- date,
- id,
- logoOrAvatar,
- icon,
- iconColor,
- onUploadPicture,
- title,
- loading,
- isMobile = false,
-}: ShowPageSummaryCardProps) => {
- const { localeCatalog } = useAtomStateValue(dateLocaleState);
- const beautifiedCreatedAt =
- date !== '' ? beautifyPastDateRelativeToNow(date, localeCatalog) : '';
- const exactCreatedAt = date !== '' ? beautifyExactDateTime(date) : '';
- const instanceId = useId();
- const dateElementId = `date-id-${instanceId}`;
- const inputFileRef = useRef<HTMLInputElement>(null);
- const onFileChange = (e: ChangeEvent<HTMLInputElement>) => {
- if (isDefined(e.target.files)) onUploadPicture?.(e.target.files[0]);
- };
-
- const handleAvatarClick = () => {
- inputFileRef?.current?.click?.();
- };
-
- if (loading)
- return (
- <StyledShowPageSummaryCard isMobile={isMobile}>
- <StyledShowPageSummaryCardSkeletonLoader />
- </StyledShowPageSummaryCard>
- );
-
- return (
- <StyledShowPageSummaryCard isMobile={isMobile}>
- <StyledAvatarWrapper
- isAvatarEditable={isDefined(onUploadPicture)}
- hasIcon={isDefined(icon)}
- >
- <Avatar
- avatarUrl={getAbsoluteImageUrl(logoOrAvatar)}
- onClick={onUploadPicture ? handleAvatarClick : undefined}
- size="xl"
- placeholderColorSeed={id}
- placeholder={avatarPlaceholder}
- type={icon ? 'icon' : avatarType}
- Icon={icon}
- iconColor={iconColor}
- />
- <StyledFileInput
- ref={inputFileRef}
- onChange={onFileChange}
- type="file"
- />
- </StyledAvatarWrapper>
- <StyledInfoContainer isMobile={isMobile}>
- <StyledTitle isMobile={isMobile}>{title}</StyledTitle>
- {beautifiedCreatedAt && (
- <StyledDate isMobile={isMobile} id={dateElementId}>
- <Trans>Added {beautifiedCreatedAt}</Trans>
- </StyledDate>
- )}
- <AppTooltip
- anchorSelect={`#${dateElementId}`}
- content={exactCreatedAt}
- clickable
- noArrow
- place="right"
- />
- </StyledInfoContainer>
- </StyledShowPageSummaryCard>
- );
-};
diff --git a/packages/twenty-front/src/modules/ui/layout/tab-list/components/TabListHiddenMeasurements.tsx b/packages/twenty-front/src/modules/ui/layout/tab-list/components/TabListHiddenMeasurements.tsx
index 2703bc423c7..ef18d00c2d3 100644
--- a/packages/twenty-front/src/modules/ui/layout/tab-list/components/TabListHiddenMeasurements.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/tab-list/components/TabListHiddenMeasurements.tsx
@@ -59,7 +59,9 @@ export const TabListHiddenMeasurements = ({
))}
<NodeDimension onDimensionChange={onMoreButtonWidthChange}>
- <TabMoreButton hiddenTabsCount={1} active={false} />
+ {/* Measured with the highest count it can ever display, so the widest
+ label is reserved and the last visible tab is never clipped by it. */}
+ <TabMoreButton hiddenTabsCount={visibleTabs.length} active={false} />
</NodeDimension>
{onAddButtonWidthChange && (
diff --git a/packages/twenty-front/src/modules/ui/layout/tab-list/components/TabMoreButton.tsx b/packages/twenty-front/src/modules/ui/layout/tab-list/components/TabMoreButton.tsx
index df41923a1b8..3fc4218e0a0 100644
--- a/packages/twenty-front/src/modules/ui/layout/tab-list/components/TabMoreButton.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/tab-list/components/TabMoreButton.tsx
@@ -4,10 +4,14 @@ import { IconChevronDown } from 'twenty-ui/icon';
import { TabButton } from 'twenty-ui/input';
import { TAB_LIST_HEIGHT } from '@/ui/layout/tab-list/constants/TabListHeight';
+import { TAB_LIST_ROW_HEIGHT_CSS_VARIABLE } from '@/ui/layout/tab-list/constants/TabListRowHeightCssVariable';
+// The dropdown wraps its clickable component in a fit-content box, so the row
+// height cannot be inherited and reaches the button through the variable the
+// tab list sets.
const StyledTabMoreButtonContainer = styled.div`
display: flex;
- height: ${TAB_LIST_HEIGHT};
+ height: var(${TAB_LIST_ROW_HEIGHT_CSS_VARIABLE}, ${TAB_LIST_HEIGHT});
`;
export const TabMoreButton = ({
diff --git a/packages/twenty-front/src/modules/ui/layout/tab-list/constants/TabListPadding.ts b/packages/twenty-front/src/modules/ui/layout/tab-list/constants/TabListPadding.ts
index 682a570a198..f74fad20000 100644
--- a/packages/twenty-front/src/modules/ui/layout/tab-list/constants/TabListPadding.ts
+++ b/packages/twenty-front/src/modules/ui/layout/tab-list/constants/TabListPadding.ts
@@ -1 +1 @@
-export const TAB_LIST_LEFT_PADDING = 8;
+export const TAB_LIST_HORIZONTAL_PADDING = 8;
diff --git a/packages/twenty-front/src/modules/ui/layout/tab-list/constants/TabListRowHeightCssVariable.ts b/packages/twenty-front/src/modules/ui/layout/tab-list/constants/TabListRowHeightCssVariable.ts
new file mode 100644
index 00000000000..ff1d7d99853
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/layout/tab-list/constants/TabListRowHeightCssVariable.ts
@@ -0,0 +1 @@
+export const TAB_LIST_ROW_HEIGHT_CSS_VARIABLE = '--tab-list-row-height';
diff --git a/packages/twenty-front/src/modules/ui/layout/tab-list/hooks/__tests__/useTabListMeasurements.test.ts b/packages/twenty-front/src/modules/ui/layout/tab-list/hooks/__tests__/useTabListMeasurements.test.ts
new file mode 100644
index 00000000000..5fefb1f6efb
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/layout/tab-list/hooks/__tests__/useTabListMeasurements.test.ts
@@ -0,0 +1,144 @@
+import { useTabListMeasurements } from '@/ui/layout/tab-list/hooks/useTabListMeasurements';
+import { type SingleTabProps } from '@/ui/layout/tab-list/types/SingleTabProps';
+import { act, renderHook } from '@testing-library/react';
+
+const VISIBLE_TABS = [
+ { id: 'first-tab', title: 'First tab' },
+ { id: 'second-tab', title: 'Second tab' },
+];
+
+const renderMeasuredTabList = ({
+ rightPadding = 0,
+ hasAddButton = false,
+ containerWidth = 212,
+ visibleTabs = VISIBLE_TABS,
+}: {
+ rightPadding?: number;
+ hasAddButton?: boolean;
+ containerWidth?: number;
+ visibleTabs?: SingleTabProps[];
+} = {}) => {
+ const hook = renderHook(
+ ({ rightPadding, visibleTabs, hasAddButton }) =>
+ useTabListMeasurements({
+ visibleTabs,
+ hasAddButton,
+ rightPadding,
+ }),
+ { initialProps: { rightPadding, visibleTabs, hasAddButton } },
+ );
+
+ act(() => {
+ for (const tab of visibleTabs) {
+ hook.result.current.onTabWidthChange(tab.id)({ width: 100, height: 48 });
+ }
+ hook.result.current.onMoreButtonWidthChange({ width: 70, height: 48 });
+ hook.result.current.onAddButtonWidthChange({ width: 80, height: 48 });
+ hook.result.current.onContainerWidthChange({
+ width: containerWidth,
+ height: 48,
+ });
+ });
+
+ return hook;
+};
+
+describe('useTabListMeasurements', () => {
+ it('should update overflow when padding changes without a container resize', () => {
+ const { result, rerender } = renderMeasuredTabList();
+
+ rerender({
+ rightPadding: 8,
+ visibleTabs: VISIBLE_TABS,
+ hasAddButton: false,
+ });
+
+ expect(result.current.hiddenTabs).toEqual([VISIBLE_TABS[1]]);
+
+ rerender({
+ rightPadding: 0,
+ visibleTabs: VISIBLE_TABS,
+ hasAddButton: false,
+ });
+
+ expect(result.current.hiddenTabs).toEqual([]);
+ });
+
+ it('should bring tabs back one by one as the container widens again', () => {
+ const { result } = renderMeasuredTabList({ containerWidth: 40 });
+
+ expect(result.current.visibleTabCount).toBe(0);
+
+ act(() =>
+ result.current.onContainerWidthChange({ width: 182, height: 48 }),
+ );
+
+ expect(result.current.visibleTabCount).toBe(1);
+ expect(result.current.hiddenTabs).toEqual([VISIBLE_TABS[1]]);
+
+ act(() =>
+ result.current.onContainerWidthChange({ width: 212, height: 48 }),
+ );
+
+ expect(result.current.visibleTabCount).toBe(2);
+ expect(result.current.hiddenTabs).toEqual([]);
+ });
+
+ it('should recover from an empty row when the new-tab button goes away', () => {
+ const { result, rerender } = renderMeasuredTabList({
+ rightPadding: 8,
+ hasAddButton: true,
+ containerWidth: 200,
+ });
+
+ expect(result.current.visibleTabCount).toBe(0);
+
+ rerender({
+ rightPadding: 8,
+ visibleTabs: VISIBLE_TABS,
+ hasAddButton: false,
+ });
+
+ expect(result.current.visibleTabCount).toBe(1);
+ expect(result.current.hiddenTabs).toEqual([VISIBLE_TABS[1]]);
+ });
+
+ it('should not overflow the row while a newly added tab is unmeasured', () => {
+ const addedTab = { id: 'added-tab', title: 'Added tab' };
+ const { result, rerender } = renderMeasuredTabList();
+
+ rerender({
+ rightPadding: 0,
+ visibleTabs: [addedTab, ...VISIBLE_TABS],
+ hasAddButton: false,
+ });
+
+ expect(result.current.visibleTabCount).toBe(1);
+
+ act(() =>
+ result.current.onTabWidthChange(addedTab.id)({ width: 20, height: 48 }),
+ );
+
+ expect(result.current.visibleTabCount).toBe(2);
+ expect(result.current.hiddenTabs).toEqual([VISIBLE_TABS[1]]);
+ });
+
+ it('should bring a tab back when another one is removed without a remeasure', () => {
+ const thirdTab = { id: 'third-tab', title: 'Third tab' };
+ const { result, rerender } = renderMeasuredTabList({
+ visibleTabs: [...VISIBLE_TABS, thirdTab],
+ });
+
+ expect(result.current.visibleTabCount).toBe(1);
+ expect(result.current.hiddenTabs).toEqual([VISIBLE_TABS[1], thirdTab]);
+
+ rerender({
+ rightPadding: 0,
+ visibleTabs: VISIBLE_TABS,
+ hasAddButton: false,
+ });
+
+ expect(result.current.visibleTabCount).toBe(2);
+ expect(result.current.hiddenTabs).toEqual([]);
+ });
+});
diff --git a/packages/twenty-front/src/modules/ui/layout/tab-list/hooks/useTabListMeasurements.ts b/packages/twenty-front/src/modules/ui/layout/tab-list/hooks/useTabListMeasurements.ts
index d76136830cd..97ef1408189 100644
--- a/packages/twenty-front/src/modules/ui/layout/tab-list/hooks/useTabListMeasurements.ts
+++ b/packages/twenty-front/src/modules/ui/layout/tab-list/hooks/useTabListMeasurements.ts
@@ -8,6 +8,7 @@ import { calculateVisibleTabCount } from '@/ui/layout/tab-list/utils/calculateVi
type UseTabListMeasurementsOptions = {
visibleTabs: SingleTabProps[];
hasAddButton?: boolean;
+ rightPadding?: number;
};
type UseTabListMeasurementsResult = {
@@ -24,6 +25,7 @@ type UseTabListMeasurementsResult = {
export const useTabListMeasurements = ({
visibleTabs,
hasAddButton = false,
+ rightPadding = 0,
}: UseTabListMeasurementsOptions): UseTabListMeasurementsResult => {
const [tabWidthsById, setTabWidthsById] = useState<TabWidthsById>({});
const [containerWidth, setContainerWidth] = useState(0);
@@ -37,6 +39,7 @@ export const useTabListMeasurements = ({
containerWidth,
moreButtonWidth,
addButtonWidth: hasAddButton ? addButtonWidth : 0,
+ rightPadding,
});
}, [
visibleTabs,
@@ -45,6 +48,7 @@ export const useTabListMeasurements = ({
moreButtonWidth,
addButtonWidth,
hasAddButton,
+ rightPadding,
]);
const hiddenTabs = useMemo(() => {
diff --git a/packages/twenty-front/src/modules/ui/layout/tab-list/utils/__tests__/calculateVisibleTabCount.test.ts b/packages/twenty-front/src/modules/ui/layout/tab-list/utils/__tests__/calculateVisibleTabCount.test.ts
new file mode 100644
index 00000000000..dc42409555d
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/layout/tab-list/utils/__tests__/calculateVisibleTabCount.test.ts
@@ -0,0 +1,129 @@
+import { calculateVisibleTabCount } from '@/ui/layout/tab-list/utils/calculateVisibleTabCount';
+
+const VISIBLE_TABS = [
+ { id: 'first-tab', title: 'First tab' },
+ { id: 'second-tab', title: 'Second tab' },
+];
+
+const MEASUREMENTS = {
+ visibleTabs: VISIBLE_TABS,
+ tabWidthsById: { 'first-tab': 100, 'second-tab': 100 },
+ moreButtonWidth: 70,
+};
+
+describe('calculateVisibleTabCount', () => {
+ it.each([
+ {
+ description: 'fits both standalone tabs exactly',
+ containerWidth: 212,
+ rightPadding: 0,
+ addButtonWidth: 0,
+ expected: 2,
+ },
+ {
+ description: 'reserves identifier-bar right padding',
+ containerWidth: 212,
+ rightPadding: 8,
+ addButtonWidth: 0,
+ expected: 1,
+ },
+ {
+ description: 'fits both tabs with right padding',
+ containerWidth: 220,
+ rightPadding: 8,
+ addButtonWidth: 0,
+ expected: 2,
+ },
+ {
+ description: 'reserves the add button and right padding',
+ containerWidth: 296,
+ rightPadding: 8,
+ addButtonWidth: 80,
+ expected: 1,
+ },
+ {
+ description: 'fits both tabs beside the add button',
+ containerWidth: 304,
+ rightPadding: 8,
+ addButtonWidth: 80,
+ expected: 2,
+ },
+ {
+ description: 'overflows all tabs when the first cannot fit beside More',
+ containerWidth: 181,
+ rightPadding: 0,
+ addButtonWidth: 0,
+ expected: 0,
+ },
+ {
+ description: 'fits the first tab and More exactly',
+ containerWidth: 182,
+ rightPadding: 0,
+ addButtonWidth: 0,
+ expected: 1,
+ },
+ {
+ description: 'overflows all tabs in a very narrow row',
+ containerWidth: 40,
+ rightPadding: 0,
+ addButtonWidth: 0,
+ expected: 0,
+ },
+ {
+ description: 'overflows all tabs when the add button takes their space',
+ containerWidth: 200,
+ rightPadding: 8,
+ addButtonWidth: 80,
+ expected: 0,
+ },
+ {
+ description: 'keeps tabs visible until the container is measured',
+ containerWidth: 0,
+ rightPadding: 0,
+ addButtonWidth: 0,
+ expected: 2,
+ },
+ ])(
+ '$description',
+ ({ containerWidth, rightPadding, addButtonWidth, expected }) => {
+ expect(
+ calculateVisibleTabCount({
+ ...MEASUREMENTS,
+ containerWidth,
+ rightPadding,
+ addButtonWidth,
+ }),
+ ).toBe(expected);
+ },
+ );
+
+ it('keeps tabs visible until a tab is measured', () => {
+ expect(
+ calculateVisibleTabCount({
+ ...MEASUREMENTS,
+ tabWidthsById: {},
+ containerWidth: 40,
+ }),
+ ).toBe(2);
+ });
+
+ it('uses the widest known tab for a newly added unmeasured tab', () => {
+ expect(
+ calculateVisibleTabCount({
+ ...MEASUREMENTS,
+ visibleTabs: [{ id: 'added-tab', title: 'Added tab' }, ...VISIBLE_TABS],
+ containerWidth: 212,
+ }),
+ ).toBe(1);
+ });
+
+ it('returns no visible tabs for an empty list', () => {
+ expect(
+ calculateVisibleTabCount({
+ ...MEASUREMENTS,
+ visibleTabs: [],
+ containerWidth: 212,
+ }),
+ ).toBe(0);
+ });
+});
diff --git a/packages/twenty-front/src/modules/ui/layout/tab-list/utils/calculateVisibleTabCount.ts b/packages/twenty-front/src/modules/ui/layout/tab-list/utils/calculateVisibleTabCount.ts
index fad27106297..594d1eace23 100644
--- a/packages/twenty-front/src/modules/ui/layout/tab-list/utils/calculateVisibleTabCount.ts
+++ b/packages/twenty-front/src/modules/ui/layout/tab-list/utils/calculateVisibleTabCount.ts
@@ -1,5 +1,5 @@
import { TAB_LIST_GAP } from '@/ui/layout/tab-list/constants/TabListGap';
-import { TAB_LIST_LEFT_PADDING } from '@/ui/layout/tab-list/constants/TabListPadding';
+import { TAB_LIST_HORIZONTAL_PADDING } from '@/ui/layout/tab-list/constants/TabListPadding';
import { type SingleTabProps } from '@/ui/layout/tab-list/types/SingleTabProps';
import { type TabWidthsById } from '@/ui/layout/tab-list/types/TabWidthsById';
import { isDefined } from 'twenty-shared/utils';
@@ -10,6 +10,7 @@ type CalculateVisibleTabCountParams = {
containerWidth: number;
moreButtonWidth: number;
addButtonWidth?: number;
+ rightPadding?: number;
};
export const calculateVisibleTabCount = ({
@@ -18,34 +19,43 @@ export const calculateVisibleTabCount = ({
containerWidth,
moreButtonWidth,
addButtonWidth = 0,
+ rightPadding = 0,
}: CalculateVisibleTabCountParams): number => {
- if (Object.keys(tabWidthsById).length === 0 || containerWidth === 0) {
+ const measuredTabWidths = visibleTabs
+ .map((tab) => tabWidthsById[tab.id])
+ .filter(isDefined);
+
+ if (measuredTabWidths.length === 0 || containerWidth === 0) {
return visibleTabs.length;
}
+ // A tab added in this render is measured one commit later; standing in the
+ // widest known tab keeps the row from overflowing until its width arrives.
+ const unmeasuredTabWidth = Math.max(...measuredTabWidths);
+
const availableWidth =
containerWidth -
- TAB_LIST_LEFT_PADDING -
+ TAB_LIST_HORIZONTAL_PADDING -
+ rightPadding -
(addButtonWidth > 0 ? addButtonWidth + TAB_LIST_GAP : 0);
let totalWidth = 0;
- for (let i = 0; i < visibleTabs.length; i++) {
- const tab = visibleTabs[i];
- const tabWidth = tabWidthsById[tab.id];
- if (!isDefined(tabWidth)) {
- return visibleTabs.length;
- }
+ for (let i = 0; i < visibleTabs.length; i++) {
+ const tabWidth = tabWidthsById[visibleTabs[i].id] ?? unmeasuredTabWidth;
- const gapsWidth = i > 0 ? TAB_LIST_GAP : 0;
- const potentialMoreButtonWidth =
- i < visibleTabs.length - 1 ? moreButtonWidth + TAB_LIST_GAP : 0;
+ totalWidth += i > 0 ? TAB_LIST_GAP + tabWidth : tabWidth;
- totalWidth += tabWidth + gapsWidth;
+ const overflowButtonWidth =
+ i < visibleTabs.length - 1 ? TAB_LIST_GAP + moreButtonWidth : 0;
- if (totalWidth + potentialMoreButtonWidth > availableWidth) {
- return Math.max(1, i);
+ if (totalWidth + overflowButtonWidth > availableWidth) {
+ // Keeping a tab that does not fit next to the overflow button would clip
+ // it against the row and leave it out of the menu, so it goes to overflow
+ // together with everything after it, even when nothing is left on the row.
+ return i;
}
}
+
return visibleTabs.length;
};