The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Hide anchored tooltips when the anchor is hidden (#28064)
Raphaël Bosia0134c19c107
diff --git a/packages/twenty-docs/ui/primitives/surfaces/tooltip.mdx b/packages/twenty-docs/ui/primitives/surfaces/tooltip.mdxindex acf5cd7cff2..8c9eaae22ac 100644--- a/packages/twenty-docs/ui/primitives/surfaces/tooltip.mdx+++ b/packages/twenty-docs/ui/primitives/surfaces/tooltip.mdx@@ -152,7 +152,7 @@ Setting `disabled` on shorthand or Root suppresses the tooltip itself. Trigger `## Placement and overflowing text-Shorthand defaults to `side="top"`, `align="center"`, `sideOffset={10}`, and a maximum width of `300` pixels. Placement adjusts to available space. Use `arrow` for an arrow and `container` to override the theme's portal destination; see [theming](/ui/theming).+Shorthand defaults to `side="top"`, `align="center"`, `sideOffset={10}`, and a maximum width of `300` pixels. Placement adjusts to available space. An open tooltip hides while its anchor is scrolled out of view, including out of a scroll container. Use `arrow` for an arrow and `container` to override the theme's portal destination; see [theming](/ui/theming).Use [OverflowingTextWithTooltip](/ui/primitives/typography/overflowing-text-with-tooltip) when a text label should show its full value only when truncated. Its existing `text`, `tooltipContent`, and `tooltipPlace` props remain available.diff --git a/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionItemPreviewTooltip.tsx b/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionItemPreviewTooltip.tsxindex cfebbb1b0f2..99f00788f0e 100644--- a/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionItemPreviewTooltip.tsx+++ b/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionItemPreviewTooltip.tsx@@ -11,10 +11,6 @@ const previewTooltipClass = css`border-radius: ${themeCssVariables.border.radius.md};box-shadow: ${themeCssVariables.boxShadow.strong};padding: 0;-- [data-anchor-hidden] & {- visibility: hidden;- }`;type SuggestionItemPreviewTooltipProps = {diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/Tooltip.module.scss b/packages/twenty-ui/src/primitives/surfaces/Tooltip/Tooltip.module.scssindex 6311c2038db..1f79be2681c 100644--- a/packages/twenty-ui/src/primitives/surfaces/Tooltip/Tooltip.module.scss+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/Tooltip.module.scss@@ -1,5 +1,9 @@.positioner {z-index: var(--t-last-layer-z-index);++ &[data-anchor-hidden] {+ visibility: hidden;+ }}.popup {diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/__stories__/Tooltip.stories.module.scss b/packages/twenty-ui/src/primitives/surfaces/Tooltip/__stories__/Tooltip.stories.module.scssnew file mode 100644index 00000000000..382c4162f86--- /dev/null+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/__stories__/Tooltip.stories.module.scss@@ -0,0 +1,4 @@+.scrollArea {+ block-size: 120px;+ overflow: auto;+}diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/__stories__/Tooltip.stories.module.scss.d.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/__stories__/Tooltip.stories.module.scss.d.tsnew file mode 100644index 00000000000..0c585e71165--- /dev/null+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/__stories__/Tooltip.stories.module.scss.d.ts@@ -0,0 +1,4 @@+declare const classNames: {+ readonly scrollArea: 'scrollArea';+};+export default classNames;diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/__stories__/Tooltip.stories.tsx b/packages/twenty-ui/src/primitives/surfaces/Tooltip/__stories__/Tooltip.stories.tsxindex bc99768f979..d1d32475c5a 100644--- a/packages/twenty-ui/src/primitives/surfaces/Tooltip/__stories__/Tooltip.stories.tsx+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/__stories__/Tooltip.stories.tsx@@ -8,6 +8,7 @@ import { Text } from '@ui/primitives/typography/Text/Text';import { ComponentDecorator } from '@ui/testing';import { Tooltip } from '../Tooltip';+import styles from './Tooltip.stories.module.scss';const findTooltip = async (canvasElement: HTMLElement) => {const tooltip = await within(canvasElement.ownerDocument.body).findByRole(@@ -198,6 +199,44 @@ export const Hidden: Story = {},};+const ACTIVITY_LOG_ENTRIES = Array.from(+ { length: 12 },+ (_, index) => `Activity entry ${index + 1}`,+);++export const AnchorScrolledOut: Story = {+ args: { open: true },+ render: (args) => (+ <div+ role="region"+ aria-label="Activity log"+ tabIndex={0}+ className={styles.scrollArea}+ >+ <Tooltip {...args}>+ <Button>Show details</Button>+ </Tooltip>+ {ACTIVITY_LOG_ENTRIES.map((entry) => (+ <p key={entry}>{entry}</p>+ ))}+ </div>+ ),+ play: async ({ canvasElement }) => {+ const activityLog = within(canvasElement).getByRole('region', {+ name: 'Activity log',+ });+ const tooltip = await findTooltip(canvasElement);++ activityLog.scrollTop = activityLog.scrollHeight;++ await waitFor(() => expect(tooltip).not.toBeVisible());++ activityLog.scrollTop = 0;++ await waitFor(() => expect(tooltip).toBeVisible());+ },+};+const PartContractExample = () => {const popupRef = useRef<HTMLDivElement>(null);const [reason, setReason] = useState('closed');