Skip to content

The open alternative to Salesforce, designed for AI.

Fix front scale drift (#28060)

BOHEUS1a039c9a4265
diff --git a/packages/twenty-docs/snippets/ui/generated/surfaces/tooltip.mdx b/packages/twenty-docs/snippets/ui/generated/surfaces/tooltip.mdx
index 59bee50d802..55c9ce9f28b 100644
--- a/packages/twenty-docs/snippets/ui/generated/surfaces/tooltip.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/surfaces/tooltip.mdx
@@ -462,6 +462,10 @@
returns a class based on the component's state.
</ParamField>
+<ParamField body="Popup.maxWidth" type="MaxWidth&lt;string | number&gt;">
+ Maximum popup width, still capped by the space available beside the anchor.
+</ParamField>
+
<ParamField body="Popup.ref" type="Ref&lt;HTMLDivElement&gt;">
Ref to the popup div. Native props, styles and render target this element.
</ParamField>
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/components/FieldDescriptionTooltipProvider.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/components/FieldDescriptionTooltipProvider.tsx
index 28a7d3e7829..47fd9b3e0c8 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/ui/components/FieldDescriptionTooltipProvider.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/components/FieldDescriptionTooltipProvider.tsx
@@ -52,9 +52,8 @@ export const FieldDescriptionTooltipProvider = ({
side="bottom"
positionMethod="fixed"
sideOffset={10}
- style={{ maxWidth: '300px' }}
>
- <Tooltip.Popup>
+ <Tooltip.Popup maxWidth={300}>
<TooltipTextContent description={payload?.description}>
{payload?.title}
</TooltipTextContent>
diff --git a/packages/twenty-front/src/modules/object-record/record-list/components/RecordListFieldTooltip.tsx b/packages/twenty-front/src/modules/object-record/record-list/components/RecordListFieldTooltip.tsx
index 5c2ac472da8..a0b343f99ae 100644
--- a/packages/twenty-front/src/modules/object-record/record-list/components/RecordListFieldTooltip.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-list/components/RecordListFieldTooltip.tsx
@@ -34,9 +34,8 @@ export const RecordListFieldTooltip = ({
side="bottom"
positionMethod="fixed"
sideOffset={10}
- style={{ maxWidth: '300px' }}
>
- <Tooltip.Popup>
+ <Tooltip.Popup maxWidth={300}>
<TooltipTextContent
startIcon={isDefined(FieldIcon) ? <FieldIcon /> : undefined}
>
diff --git a/packages/twenty-front/src/modules/onboarding/components/free-credits/OnboardingFreeCreditsPill.tsx b/packages/twenty-front/src/modules/onboarding/components/free-credits/OnboardingFreeCreditsPill.tsx
index 13389be83e6..5b819b2ddc2 100644
--- a/packages/twenty-front/src/modules/onboarding/components/free-credits/OnboardingFreeCreditsPill.tsx
+++ b/packages/twenty-front/src/modules/onboarding/components/free-credits/OnboardingFreeCreditsPill.tsx
@@ -264,9 +264,8 @@ export const OnboardingFreeCreditsPill = ({
side="bottom"
align="end"
sideOffset={10}
- style={{ maxWidth: '300px' }}
>
- <Tooltip.Popup withExitAnimation>
+ <Tooltip.Popup maxWidth={300} withExitAnimation>
<StyledTooltipContents>
<AnimatePresence initial={false}>
{isDefined(tooltipContent) && (
diff --git a/packages/twenty-front/src/modules/settings/ai/components/SettingsAiModelsTable.tsx b/packages/twenty-front/src/modules/settings/ai/components/SettingsAiModelsTable.tsx
index 4012c858e4d..58689390383 100644
--- a/packages/twenty-front/src/modules/settings/ai/components/SettingsAiModelsTable.tsx
+++ b/packages/twenty-front/src/modules/settings/ai/components/SettingsAiModelsTable.tsx
@@ -241,9 +241,8 @@ export const SettingsAiModelsTable = <TModel extends AiModelSummary>({
side="top"
align="end"
sideOffset={8}
- style={{ maxWidth: '320px' }}
>
- <Tooltip.Popup className={hoverCardTooltipClass}>
+ <Tooltip.Popup maxWidth={320} className={hoverCardTooltipClass}>
<SettingsAiModelHoverCard model={hoveredModel} />
</Tooltip.Popup>
</Tooltip.Positioner>
diff --git a/packages/twenty-front/src/modules/side-panel/pages/search/components/SidePanelSearchRecordsPage.tsx b/packages/twenty-front/src/modules/side-panel/pages/search/components/SidePanelSearchRecordsPage.tsx
index 8d9c02a0fa1..a280944aa02 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/search/components/SidePanelSearchRecordsPage.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/search/components/SidePanelSearchRecordsPage.tsx
@@ -127,11 +127,11 @@ export const SidePanelSearchRecordsPage = () => {
side="left"
align="start"
sideOffset={16}
- style={{
- maxWidth: `${SIDE_PANEL_SEARCH_RECORD_PREVIEW_WIDTH}px`,
- }}
>
- <Tooltip.Popup className={previewTooltipClass}>
+ <Tooltip.Popup
+ maxWidth={SIDE_PANEL_SEARCH_RECORD_PREVIEW_WIDTH}
+ className={previewTooltipClass}
+ >
<SidePanelSearchRecordPreviewCard
key={previewedItem.recordId}
objectNameSingular={previewedItem.objectNameSingular}
diff --git a/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionItemPreviewTooltip.tsx b/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionItemPreviewTooltip.tsx
index 99f00788f0e..b165b17a4d1 100644
--- a/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionItemPreviewTooltip.tsx
+++ b/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionItemPreviewTooltip.tsx
@@ -31,9 +31,8 @@ export const SuggestionItemPreviewTooltip = ({
side="right"
align="start"
sideOffset={16}
- style={{ maxWidth: `${width}px` }}
>
- <Tooltip.Popup className={previewTooltipClass}>
+ <Tooltip.Popup maxWidth={width} className={previewTooltipClass}>
{children}
</Tooltip.Popup>
</Tooltip.Positioner>
diff --git a/packages/twenty-front/src/viewport-zoom.css b/packages/twenty-front/src/viewport-zoom.css
index 566c6b72756..51459780e3a 100644
--- a/packages/twenty-front/src/viewport-zoom.css
+++ b/packages/twenty-front/src/viewport-zoom.css
@@ -13,3 +13,32 @@
[data-floating-ui-viewport] > * {
zoom: var(--t-zoom, 1);
}
+
+/* Base UI positions popups the same way. Body portals holding a positioner get
+ the inverse zoom from the document origin, and the popup restores the scale.
+ Base UI also exposes the anchor and available sizes in visual-viewport
+ pixels, so the popup reads them converted back to design pixels. Portals
+ into a container are left alone: floating-ui reads the zoom from there. */
+
+body > [data-base-ui-portal]:has(> [data-side]) {
+ inset-block-start: 0;
+ inset-inline-start: 0;
+ position: absolute;
+ zoom: calc(1 / var(--t-zoom, 1));
+}
+
+body > [data-base-ui-portal] > [data-side] {
+ --t-unzoomed-anchor-width: calc(var(--anchor-width) / var(--t-zoom, 1));
+ --t-unzoomed-available-width: calc(var(--available-width) / var(--t-zoom, 1));
+ --t-unzoomed-available-height: calc(
+ var(--available-height) / var(--t-zoom, 1)
+ );
+}
+
+body > [data-base-ui-portal] > [data-side] > * {
+ --anchor-width: var(--t-unzoomed-anchor-width);
+ --available-width: var(--t-unzoomed-available-width);
+ --available-height: var(--t-unzoomed-available-height);
+
+ zoom: var(--t-zoom, 1);
+}
diff --git a/packages/twenty-ui/docs/tooltipPartPropDescriptions.ts b/packages/twenty-ui/docs/tooltipPartPropDescriptions.ts
index 8753f8ce8c0..01ffee129b4 100644
--- a/packages/twenty-ui/docs/tooltipPartPropDescriptions.ts
+++ b/packages/twenty-ui/docs/tooltipPartPropDescriptions.ts
@@ -29,6 +29,8 @@ export const TOOLTIP_PART_PROP_DESCRIPTIONS = {
'Content rendered as supplied. Does not create a portal, positioner, title layout or arrow.',
ref: 'Ref to the popup div. Native props, styles and render target this element.',
withExitAnimation: 'Enables the optional Twenty exit transition.',
+ maxWidth:
+ 'Maximum popup width, still capped by the space available beside the anchor.',
},
Arrow: {
ref: 'Ref to the arrow div. Compose inside Popup.',
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index f736b44f6be..eaaffaf9661 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -9725,6 +9725,13 @@
"defaultValue": null,
"description": "CSS class applied to the element, or a function that\nreturns a class based on the component's state."
},
+ {
+ "name": "maxWidth",
+ "type": "MaxWidth<string | number>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Maximum popup width, still capped by the space available beside the anchor."
+ },
{
"name": "ref",
"type": "Ref<HTMLDivElement>",
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/Tooltip.module.scss b/packages/twenty-ui/src/primitives/surfaces/Tooltip/Tooltip.module.scss
index 1f79be2681c..68ecc5d7758 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Tooltip/Tooltip.module.scss
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/Tooltip.module.scss
@@ -19,7 +19,10 @@
padding: var(--t-spacing-1) var(--t-spacing-1_5);
word-break: break-word;
inline-size: max-content;
- max-inline-size: min(100%, var(--available-width));
+ max-inline-size: min(
+ var(--tw-tooltip-max-width, var(--available-width)),
+ var(--available-width)
+ );
will-change: opacity;
transition: opacity 0.15s ease-out;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipComponent.tsx b/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipComponent.tsx
index e814a6c6ca7..29b4ce964bc 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipComponent.tsx
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipComponent.tsx
@@ -104,10 +104,9 @@ export const TooltipComponent = <TPayload,>({
sticky={sticky}
arrowPadding={arrowPadding}
disableAnchorTracking={disableAnchorTracking}
- style={{ maxWidth }}
{...positionerProps}
>
- <TooltipPopup {...popupProps}>
+ <TooltipPopup maxWidth={maxWidth} {...popupProps}>
{hasTextLayout ? (
<TooltipBody description={description} startIcon={startIcon}>
{resolvedContent}
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipPopup.tsx b/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipPopup.tsx
index 0babb465e09..4d84685b02e 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipPopup.tsx
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipPopup.tsx
@@ -1,4 +1,6 @@
import { Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+import { isFunction, isNumber } from '@sniptt/guards';
+import { type CSSProperties } from 'react';
import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';
@@ -8,6 +10,8 @@ import { type TooltipPopupProps } from '../types/TooltipPopupProps';
export const TooltipPopup = ({
className,
withExitAnimation = false,
+ maxWidth,
+ style,
...props
}: TooltipPopupProps) => (
<TooltipPrimitive.Popup
@@ -15,5 +19,13 @@ export const TooltipPopup = ({
data-with-exit-animation={withExitAnimation || undefined}
{...props}
className={mergeClassNames(styles.popup, className)}
+ style={(state) =>
+ ({
+ '--tw-tooltip-max-width': isNumber(maxWidth)
+ ? `${maxWidth}px`
+ : maxWidth,
+ ...(isFunction(style) ? style(state) : style),
+ }) as CSSProperties
+ }
/>
);
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPopupProps.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPopupProps.ts
index a89d94614cd..06529640a4e 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPopupProps.ts
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPopupProps.ts
@@ -1,5 +1,7 @@
import { type Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+import { type CSSProperties } from 'react';
export type TooltipPopupProps = TooltipPrimitive.Popup.Props & {
withExitAnimation?: boolean;
+ maxWidth?: CSSProperties['maxWidth'];
};
diff --git a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.tsx b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.tsx
index 86489d66852..50b34c382bc 100644
--- a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.tsx
+++ b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.tsx
@@ -137,13 +137,9 @@ export const OverflowingTextWithTooltip = memo(
render={textElement}
/>
<Tooltip.Portal>
- <Tooltip.Positioner
- sideOffset={5}
- side={tooltipPlace}
- positionMethod="absolute"
- style={{ maxWidth: '300px' }}
- >
+ <Tooltip.Positioner sideOffset={5} side={tooltipPlace}>
<Tooltip.Popup
+ maxWidth={300}
className={
isTooltipMultiline ? styles.multilineTooltip : undefined
}