Skip to content

The open alternative to Salesforce, designed for AI.

Make typography composition explicit (#27504)

Raphaël Bosi9feef1c0d6ca
diff --git a/packages/twenty-docs/snippets/ui/generated/typography/overflowing-text-with-tooltip.mdx b/packages/twenty-docs/snippets/ui/generated/typography/overflowing-text-with-tooltip.mdx
index 7135445c80d..127f841638c 100644
--- a/packages/twenty-docs/snippets/ui/generated/typography/overflowing-text-with-tooltip.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/typography/overflowing-text-with-tooltip.mdx
@@ -15,28 +15,28 @@
Allows the tooltip even when the text is not truncated.
</ParamField>
-<ParamField body="displayedMaxRows" type="number">
- Maximum displayed rows. Omit for single-line truncation; use a positive integer for multiline text.
-</ParamField>
-
<ParamField body="isFocusable" type="boolean">
- Adds a tab stop and opens the tooltip on focus or click.
+ Adds an optional tab stop. Native tabIndex and focusable render elements also open the tooltip on focus.
</ParamField>
<ParamField body="isTooltipMultiline" type="boolean">
Preserves whitespace and line breaks in the tooltip.
</ParamField>
-<ParamField body="size" type="&quot;large&quot; | &quot;small&quot;">
- Small inherited text sizing or the large fixed-height treatment.
+<ParamField body="lineClamp" type="number">
+ Positive integer limiting visible lines, matching Text. Cannot be combined with `truncate`.
+</ParamField>
+
+<ParamField body="render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, {}&gt;">
+ Replaces the default div. Native props, styles, handlers and ref target the displayed text, not the popup.
</ParamField>
<ParamField body="text" type="string | number | bigint | boolean | ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | Iterable&lt;ReactNode&gt; | ReactPortal | Promise&lt;...&gt; | null | undefined" required>
- Text or React content to truncate. Non-string React content requires `tooltipContent`.
+ Caller-owned text or React content. Non-string content requires `tooltipContent`. URLs stay plain text.
</ParamField>
<ParamField body="tooltipContent" type="string">
- Plain text displayed in the tooltip. Defaults to `text` when it is a nonempty string.
+ Plain text displayed in the tooltip. Defaults to nonempty string `text`.
</ParamField>
<ParamField body="tooltipDelay" type="number">
@@ -46,3 +46,7 @@
<ParamField body="tooltipPlace" type="&quot;bottom&quot; | &quot;inline-end&quot; | &quot;inline-start&quot; | &quot;left&quot; | &quot;right&quot; | &quot;top&quot;">
Preferred side of the tooltip.
</ParamField>
+
+<ParamField body="truncate" type="boolean">
+ Single-line ellipsis by default. Set false to wrap. Cannot be combined with `lineClamp`.
+</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/typography/text.mdx b/packages/twenty-docs/snippets/ui/generated/typography/text.mdx
index 21cabd537c8..1685330010d 100644
--- a/packages/twenty-docs/snippets/ui/generated/typography/text.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/typography/text.mdx
@@ -12,18 +12,13 @@
*/}
<ParamField body="lineClamp" type="number">
- Maximum number of lines before the text is truncated with an ellipsis.
- Cannot be combined with `truncate`.
+ Positive integer limiting the number of visible lines. Cannot be combined with `truncate`.
</ParamField>
<ParamField body="render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, {}&gt;">
- Allows you to replace the component's HTML element
- with a different tag, or compose it with another component.
-
- Accepts a `ReactElement` or a function that returns the element to render.
+ Replaces the default div. Native props and the ref target the rendered text element.
</ParamField>
<ParamField body="truncate" type="boolean">
- Truncates overflowing text on one line with an ellipsis. Cannot be
- combined with `lineClamp`.
+ Truncates one line with an ellipsis. Cannot be combined with `lineClamp`.
</ParamField>
diff --git a/packages/twenty-docs/ui/primitives/typography/overflowing-text-with-tooltip.mdx b/packages/twenty-docs/ui/primitives/typography/overflowing-text-with-tooltip.mdx
index a71839ef1bc..6168f558d40 100644
--- a/packages/twenty-docs/ui/primitives/typography/overflowing-text-with-tooltip.mdx
+++ b/packages/twenty-docs/ui/primitives/typography/overflowing-text-with-tooltip.mdx
@@ -46,7 +46,7 @@ export const RecordDescription = () => (
<Text style={{ maxWidth: 220 }}>
<OverflowingTextWithTooltip
text="Review the account history, confirm the renewal date, and prepare the next conversation with the customer."
- displayedMaxRows={2}
+ lineClamp={2}
isTooltipMultiline
isFocusable
/>
@@ -54,7 +54,7 @@ export const RecordDescription = () => (
);
```
-`displayedMaxRows` limits the displayed lines; use a positive integer. `isTooltipMultiline` preserves whitespace and line breaks inside the tooltip. Without a row limit, text truncates on one line.
+`lineClamp` matches Text and limits the displayed lines; use a positive integer. `isTooltipMultiline` preserves whitespace and line breaks inside the tooltip. Without a row limit, text truncates on one line.
## Custom content and timing
@@ -77,11 +77,33 @@ export const ImportResult = () => (
);
```
-React content requires a plain-string `tooltipContent`. With string text, that prop can override the tooltip label; otherwise the text itself is used. An empty or missing label does not open a tooltip. String text also recognizes links.
+React content requires a plain-string `tooltipContent`. With string text, that prop can override the tooltip label; otherwise the text itself is used. An empty or missing label does not open a tooltip. String URLs remain plain text. Supply links explicitly in `text` or through `render`. Link content and navigation stay caller-owned.
`alwaysShowTooltip` allows the tooltip even without truncation. `tooltipDelay` controls the hover delay and defaults to 500 milliseconds. `tooltipPlace` defaults to `bottom`.
-The component supplies its text and tooltip parts internally; it does not accept children, native attributes, or a ref for its text element. Use [Text](/ui/primitives/typography/text) and [Tooltip](/ui/primitives/surfaces/tooltip) directly when you need custom composition. Interactive popup content belongs in [Popover](/ui/primitives/surfaces/popover).
+Native attributes, styles, class names, event handlers, and refs target the displayed Text element, a `div` by default. `render` can replace that element while retaining truncation and tooltip behavior. `OverflowingTextWithTooltipProps` is exported from `twenty-ui/primitives/typography`. Typography inherits from the surrounding layout. Set `truncate={false}` to wrap; choose either `truncate` or `lineClamp`. Focusable rendered elements and a caller-supplied `tabIndex` also reveal the tooltip on focus. Use [Text](/ui/primitives/typography/text) and [Tooltip](/ui/primitives/surfaces/tooltip) directly when you need custom composition. Interactive popup content belongs in [Popover](/ui/primitives/surfaces/popover).
+
+## Explicit links
+
+```tsx
+import { OverflowingTextWithTooltip } from 'twenty-ui/primitives/typography';
+
+export const DocumentationLink = () => (
+ <OverflowingTextWithTooltip
+ text="https://twenty.com/developers"
+ render={
+ <a href="https://twenty.com/developers" aria-label="Documentation" />
+ }
+ style={{ maxWidth: 160, display: 'block' }}
+ />
+);
+```
+
+Use a single anchor for the whole label, or supply individual anchors in React content with a plain `tooltipContent`. The component adds no anchors of its own. Keep tooltip content informational.
+
+## Migration
+
+Replace `displayedMaxRows` with `lineClamp`. The removed `size` option controlled height, not font size; use native `style` or `className` for sizing. Move intentional URL recognition into caller-owned content. No automatic linkification remains in this component.
## Props
diff --git a/packages/twenty-docs/ui/primitives/typography/shortcut.mdx b/packages/twenty-docs/ui/primitives/typography/shortcut.mdx
index 42a7933f27b..c1097aee61d 100644
--- a/packages/twenty-docs/ui/primitives/typography/shortcut.mdx
+++ b/packages/twenty-docs/ui/primitives/typography/shortcut.mdx
@@ -12,7 +12,7 @@ import ShortcutReference from '/snippets/ui/generated/typography/shortcut.mdx';
height={200}
/>
-Import `Shortcut` and `formatShortcut` from `twenty-ui/primitives/typography`. Both share the same model, symbols, and separators. Register shortcuts in your application.
+Import `Shortcut` and `formatShortcut` from `twenty-ui/primitives/typography`. Both share the same model, symbols, and separators. Register shortcuts in your application. `Shortcut` only formats the hint; it does not register keyboard actions. Native attributes, event handlers, styles, class names, and refs target its outer span. `ShortcutProps` and `ShortcutFormatOptions` are public types.
```tsx
import { Shortcut, formatShortcut } from 'twenty-ui/primitives/typography';
diff --git a/packages/twenty-docs/ui/primitives/typography/text.mdx b/packages/twenty-docs/ui/primitives/typography/text.mdx
index 7d60ca19ceb..86a3c917531 100644
--- a/packages/twenty-docs/ui/primitives/typography/text.mdx
+++ b/packages/twenty-docs/ui/primitives/typography/text.mdx
@@ -60,6 +60,6 @@ Truncation affects the visual presentation; it does not shorten the text in the
## Props
-Native attributes, children, refs, class names, and styles are also accepted.
+Native attributes, children, refs, class names, and styles target the rendered text element. `TextProps` is exported from `twenty-ui/primitives/typography`. Text content is rendered unchanged, including caller-provided links.
<TextReference />
diff --git a/packages/twenty-e2e-testing/lib/pom/helper/insertFieldData.ts b/packages/twenty-e2e-testing/lib/pom/helper/insertFieldData.ts
index 2b545cecf9e..05f849135f6 100644
--- a/packages/twenty-e2e-testing/lib/pom/helper/insertFieldData.ts
+++ b/packages/twenty-e2e-testing/lib/pom/helper/insertFieldData.ts
@@ -46,9 +46,7 @@ export class InsertFieldData {
'//span[contains(., "COUNTRY")]/../div[last()]/div',
);
this.arrayValueInput = page.locator("//input[@placeholder='Enter value']");
- this.arrayAddValueButton = page.locator(
- "//div[@data-testid='tooltip' and contains(.,'Add item')]",
- );
+ this.arrayAddValueButton = page.getByText('Add item', { exact: true });
this.currencySelect = page.locator(
'//body/div[last()]/div/div/div[first()]/div/div',
);
@@ -57,24 +55,14 @@ export class InsertFieldData {
this.yearSelect;
this.previousMonthButton;
this.nextMonthButton;
- this.clearDateButton = page.locator(
- "//div[@data-testid='tooltip' and contains(., 'Clear')]",
- );
+ this.clearDateButton = page.getByText('Clear', { exact: true });
this.dateInput = page.locator("//input[@placeholder='Type date and time']");
this.firstNameInput = page.locator("//input[@placeholder='First name']"); // may fail if placeholder is `F&zwnj;&zwnj;irst name` instead of `First name`
this.lastNameInput = page.locator("//input[@placeholder='Last name']"); // may fail if placeholder is `L&zwnj;&zwnj;ast name` instead of `Last name`
- this.addUrlButton = page.locator(
- "//div[@data-testid='tooltip' and contains(., 'Add URL')]",
- );
- this.setAsPrimaryButton = page.locator(
- "//div[@data-testid='tooltip' and contains(., 'Set as primary')]",
- );
- this.addPhoneButton = page.locator(
- "//div[@data-testid='tooltip' and contains(., 'Add Phone')]",
- );
- this.addMailButton = page.locator(
- "//div[@data-testid='tooltip' and contains(., 'Add Email')]",
- );
+ this.addUrlButton = page.getByText('Add URL', { exact: true });
+ this.setAsPrimaryButton = page.getByText('Set as primary', { exact: true });
+ this.addPhoneButton = page.getByText('Add Phone', { exact: true });
+ this.addMailButton = page.getByText('Add Email', { exact: true });
}
async typeAddress1(value: string) {
@@ -99,9 +87,7 @@ export class InsertFieldData {
async selectCountry(value: string) {
await this.countrySelect.click();
- await this.page
- .locator(`//div[@data-testid='tooltip' and contains(., '${value}')]`)
- .click();
+ await this.page.getByText(value).click();
}
async typeArrayValue(value: string) {
@@ -114,9 +100,7 @@ export class InsertFieldData {
async selectCurrency(value: string) {
await this.currencySelect.click();
- await this.page
- .locator(`//div[@data-testid='tooltip' and contains(., '${value}')]`)
- .click();
+ await this.page.getByText(value).click();
}
async typeCurrencyAmount(value: string) {
@@ -129,16 +113,12 @@ export class InsertFieldData {
async selectMonth(value: string) {
await this.monthSelect.click();
- await this.page
- .locator(`//div[@data-testid='tooltip' and contains(., '${value}')]`)
- .click();
+ await this.page.getByText(value).click();
}
async selectYear(value: string) {
await this.yearSelect.click();
- await this.page
- .locator(`//div[@data-testid='tooltip' and contains(., '${value}')]`)
- .click();
+ await this.page.getByText(value).click();
}
async clickPreviousMonthButton() {
@@ -190,9 +170,7 @@ export class InsertFieldData {
}
async selectValue(value: string) {
- await this.page
- .locator(`//div[@data-testid='tooltip' and contains(., '${value}')]`)
- .click();
+ await this.page.getByText(value).click();
}
async typeNumber(placeholder: string, value: string) {
@@ -202,11 +180,7 @@ export class InsertFieldData {
}
async selectCountryPhoneCode(countryCode: string) {
- await this.page
- .locator(
- `//div[@data-testid='tooltip' and contains(., '${countryCode}')]`,
- )
- .click();
+ await this.page.getByText(countryCode).click();
}
async typePhoneNumber(value: string) {
@@ -237,14 +211,10 @@ export class InsertFieldData {
}
async clickEditButton() {
- await this.page
- .locator("//div[@data-testid='tooltip' and contains(., 'Edit')]")
- .click();
+ await this.page.getByText('Edit', { exact: true }).click();
}
async clickDeleteButton() {
- await this.page
- .locator("//div[@data-testid='tooltip' and contains(., 'Delete')]")
- .click();
+ await this.page.getByText('Delete', { exact: true }).click();
}
}
diff --git a/packages/twenty-e2e-testing/lib/pom/leftMenu.ts b/packages/twenty-e2e-testing/lib/pom/leftMenu.ts
index a5abfc1cb7b..e664005bee2 100644
--- a/packages/twenty-e2e-testing/lib/pom/leftMenu.ts
+++ b/packages/twenty-e2e-testing/lib/pom/leftMenu.ts
@@ -44,10 +44,7 @@ export class LeftMenu {
async selectWorkspace(workspaceName: string) {
await this.workspaceDropdown.click();
- await this.page
- .getByTestId('tooltip')
- .filter({ hasText: workspaceName })
- .click();
+ await this.page.getByText(workspaceName, { exact: true }).click();
}
async changeLeftMenu() {
diff --git a/packages/twenty-e2e-testing/lib/pom/mainPage.ts b/packages/twenty-e2e-testing/lib/pom/mainPage.ts
index 23b4f478fd6..18a7cde71a2 100644
--- a/packages/twenty-e2e-testing/lib/pom/mainPage.ts
+++ b/packages/twenty-e2e-testing/lib/pom/mainPage.ts
@@ -1,5 +1,7 @@
import { Locator, Page } from '@playwright/test';
+const DELETED_RECORDS_LABEL_PATTERN = /^Deleted /;
+
export class MainPage {
// TODO: add missing elements (advanced filters, import/export popups)
private readonly tableViews: Locator;
@@ -32,9 +34,7 @@ export class MainPage {
constructor(public readonly page: Page) {
this.tableViews = page.getByText('·');
- this.addViewButton = page
- .getByTestId('tooltip')
- .filter({ hasText: /^Add view$/ });
+ this.addViewButton = page.getByText('Add view', { exact: true });
this.viewIconSelect = page.getByLabel('Click to select icon (');
this.viewNameInput; // can be selected using only actual value
this.viewTypeSelect = page.locator(
@@ -44,9 +44,9 @@ export class MainPage {
this.deleteViewButton = page.getByRole('button', { name: 'Delete' });
this.filterButton = page.getByText('Filter');
this.searchFieldInput = page.getByPlaceholder('Search fields');
- this.advancedFilterButton = page
- .getByTestId('tooltip')
- .filter({ hasText: /^Advanced filter$/ });
+ this.advancedFilterButton = page.getByText('Advanced filter', {
+ exact: true,
+ });
this.addFilterButton = page.getByRole('button', { name: 'Add Filter' });
this.resetFilterButton = page.getByTestId('cancel-button');
this.saveFilterAsViewButton = page.getByRole('button', {
@@ -57,18 +57,10 @@ export class MainPage {
this.optionsButton = page.getByText('Options');
this.fieldsButton = page.getByText('Fields');
this.goBackButton = page.getByTestId('dropdown-menu-header-end-icon');
- this.hiddenFieldsButton = page
- .getByTestId('tooltip')
- .filter({ hasText: /^Hidden Fields$/ });
- this.editFieldsButton = page
- .getByTestId('tooltip')
- .filter({ hasText: /^Edit Fields$/ });
- this.importButton = page
- .getByTestId('tooltip')
- .filter({ hasText: /^Import$/ });
- this.deletedRecordsButton = page
- .getByTestId('tooltip')
- .filter({ hasText: /^Deleted */ });
+ this.hiddenFieldsButton = page.getByText('Hidden Fields', { exact: true });
+ this.editFieldsButton = page.getByText('Edit Fields', { exact: true });
+ this.importButton = page.getByText('Import', { exact: true });
+ this.deletedRecordsButton = page.getByText(DELETED_RECORDS_LABEL_PATTERN);
this.createNewRecordButton = page.getByTestId('add-button');
this.addToFavoritesButton = page.getByText('Add to favorites');
this.deleteFromFavoritesButton = page.getByText('Delete from favorites');
@@ -91,7 +83,7 @@ export class MainPage {
// name can be either be 'Table' or 'Kanban'
async selectViewType(name: string) {
await this.viewTypeSelect.click();
- await this.page.getByTestId('tooltip').filter({ hasText: name }).click();
+ await this.page.getByText(name, { exact: true }).click();
}
async createView() {
@@ -134,7 +126,7 @@ export class MainPage {
//can be Ascending or Descending
async setSortOrder(name: string) {
await this.sortOrderButton.click();
- await this.page.getByTestId('tooltip').filter({ hasText: name }).click();
+ await this.page.getByText(name, { exact: true }).click();
}
async clickOptionsButton() {
diff --git a/packages/twenty-e2e-testing/lib/pom/recordDetails.ts b/packages/twenty-e2e-testing/lib/pom/recordDetails.ts
index f22dd8a459b..c941987db60 100644
--- a/packages/twenty-e2e-testing/lib/pom/recordDetails.ts
+++ b/packages/twenty-e2e-testing/lib/pom/recordDetails.ts
@@ -40,16 +40,12 @@ export class RecordDetails {
async createRelatedNote() {
await this.addShowPageButton.click();
- await this.page
- .locator('//div[@data-testid="tooltip" and contains(., "Note")]')
- .click();
+ await this.page.getByText('Note', { exact: true }).click();
}
async createRelatedTask() {
await this.addShowPageButton.click();
- await this.page
- .locator('//div[@data-testid="tooltip" and contains(., "Task")]')
- .click();
+ await this.page.getByText('Task', { exact: true }).click();
}
async clickMoreOptionsButton() {
@@ -90,22 +86,19 @@ export class RecordDetails {
async clickField(name: string) {
await this.page
- .locator(
- `//div[@data-testid='tooltip' and contains(., '${name}']/../../../div[last()]/div/div`,
- )
+ .getByText(name, { exact: true })
+ .locator('xpath=../../../div[last()]/div/div')
.click();
}
async clickFieldWithButton(name: string) {
await this.page
- .locator(
- `//div[@data-testid='tooltip' and contains(., '${name}']/../../../div[last()]/div/div`,
- )
+ .getByText(name, { exact: true })
+ .locator('xpath=../../../div[last()]/div/div')
.hover();
await this.page
- .locator(
- `//div[@data-testid='tooltip' and contains(., '${name}']/../../../div[last()]/div/div[last()]/div/button`,
- )
+ .getByText(name, { exact: true })
+ .locator('xpath=../../../div[last()]/div/div[last()]/div/button')
.click();
}
@@ -133,9 +126,7 @@ export class RecordDetails {
}
async selectRelationRecord(name: string) {
- await this.page
- .locator(`//div[@data-testid="tooltip" and contains(., "${name}")]`)
- .click();
+ await this.page.getByText(name, { exact: true }).click();
}
async searchRelationRecord(name: string) {
@@ -143,8 +134,6 @@ export class RecordDetails {
}
async createNewRelationRecord() {
- await this.page
- .locator('//div[@data-testid="tooltip" and contains(., "Add New")]')
- .click();
+ await this.page.getByText('Add New', { exact: true }).click();
}
}
diff --git a/packages/twenty-e2e-testing/lib/pom/settings/accountsSection.ts b/packages/twenty-e2e-testing/lib/pom/settings/accountsSection.ts
index 1e29ddf5bc1..ac9240619ab 100644
--- a/packages/twenty-e2e-testing/lib/pom/settings/accountsSection.ts
+++ b/packages/twenty-e2e-testing/lib/pom/settings/accountsSection.ts
@@ -11,9 +11,9 @@ export class AccountsSection {
constructor(public readonly page: Page) {
this.page = page;
this.addAccountButton = page.getByRole('button', { name: 'Add account' });
- this.deleteAccountButton = page
- .getByTestId('tooltip')
- .getByText('Remove account');
+ this.deleteAccountButton = page.getByText('Remove account', {
+ exact: true,
+ });
this.addBlocklistField = page.getByPlaceholder(
'[email protected], @apple.com',
);
@@ -46,9 +46,9 @@ export class AccountsSection {
async removeFromBlocklist(domain: string) {
await this.page
- .locator(
- `//div[@data-testid='tooltip' and contains(., '${domain}')]/../../div[last()]/button`,
- )
+ .getByText(domain, { exact: true })
+ .locator('xpath=../..')
+ .getByRole('button', { name: 'Remove from blocklist' })
.click();
}
diff --git a/packages/twenty-e2e-testing/lib/pom/settings/dataModelSection.ts b/packages/twenty-e2e-testing/lib/pom/settings/dataModelSection.ts
index aa6123b1bf4..a456562adf9 100644
--- a/packages/twenty-e2e-testing/lib/pom/settings/dataModelSection.ts
+++ b/packages/twenty-e2e-testing/lib/pom/settings/dataModelSection.ts
@@ -44,21 +44,21 @@ export class DataModelSection {
exact: true,
});
this.objectMoreOptionsButton = page.getByLabel('Object Options');
- this.editObjectButton = page.getByTestId('tooltip').getByText('Edit');
- this.deactivateMoreOptionsButton = page
- .getByTestId('tooltip')
- .getByText('Deactivate');
- this.activateMoreOptionsButton = page
- .getByTestId('tooltip')
- .getByText('Activate');
- this.deleteObjectButton = page.getByTestId('tooltip').getByText('Delete');
+ this.editObjectButton = page.getByText('Edit', { exact: true });
+ this.deactivateMoreOptionsButton = page.getByText('Deactivate', {
+ exact: true,
+ });
+ this.activateMoreOptionsButton = page.getByText('Activate', {
+ exact: true,
+ });
+ this.deleteObjectButton = page.getByText('Delete', { exact: true });
this.activeSection = page.getByText('Active', { exact: true });
this.inactiveSection = page.getByText('Inactive');
this.searchFieldInput = page.getByPlaceholder('Search a field...');
this.addFieldButton = page.getByRole('button', { name: 'Add field' });
- this.viewFieldDetailsMoreOptionsButton = page
- .getByTestId('tooltip')
- .getByText('View');
+ this.viewFieldDetailsMoreOptionsButton = page.getByText('View', {
+ exact: true,
+ });
this.nameFieldInput = page.getByPlaceholder('Employees');
this.descriptionFieldInput = page.getByPlaceholder('Write a description');
this.deactivateButton = page.getByRole('button', { name: 'Deactivate' });
diff --git a/packages/twenty-e2e-testing/lib/pom/settings/newFieldSection.ts b/packages/twenty-e2e-testing/lib/pom/settings/newFieldSection.ts
index deb092cecdb..704f26aabce 100644
--- a/packages/twenty-e2e-testing/lib/pom/settings/newFieldSection.ts
+++ b/packages/twenty-e2e-testing/lib/pom/settings/newFieldSection.ts
@@ -68,12 +68,10 @@ export class NewFieldSection {
this.multiSelectFieldLink = page.getByRole('link', {
name: 'Multi-select',
});
- this.setAsDefaultOptionButton = page
- .getByTestId('tooltip')
- .getByText('Set as default');
- this.removeOptionButton = page
- .getByTestId('tooltip')
- .getByText('Remove option');
+ this.setAsDefaultOptionButton = page.getByText('Set as default', {
+ exact: true,
+ });
+ this.removeOptionButton = page.getByText('Remove option', { exact: true });
this.addOptionButton = page.getByRole('button', { name: 'Add option' });
this.ratingFieldLink = page.getByRole('link', { name: 'Rating' });
this.JSONFieldLink = page.getByRole('link', { name: 'JSON' });
@@ -103,7 +101,7 @@ export class NewFieldSection {
async selectDefaultUnit(name: string) {
await this.currencyDefaultUnitSelect.click();
- await this.page.getByTestId('tooltip').filter({ hasText: name }).click();
+ await this.page.getByText(name, { exact: true }).click();
}
async clickEmailsType() {
@@ -148,7 +146,7 @@ export class NewFieldSection {
async selectDefaultBooleanValue(value: string) {
await this.defaultBooleanSelect.click();
- await this.page.getByTestId('tooltip').filter({ hasText: value }).click();
+ await this.page.getByText(value, { exact: true }).click();
}
async clickDateTimeType() {
@@ -215,12 +213,12 @@ export class NewFieldSection {
async selectRelationType(name: string) {
await this.relationTypeSelect.click();
- await this.page.getByTestId('tooltip').filter({ hasText: name }).click();
+ await this.page.getByText(name, { exact: true }).click();
}
async selectObjectDestination(name: string) {
await this.objectDestinationSelect.click();
- await this.page.getByTestId('tooltip').filter({ hasText: name }).click();
+ await this.page.getByText(name, { exact: true }).click();
}
async selectRelationIcon(name: string) {
diff --git a/packages/twenty-e2e-testing/lib/pom/settings/rolesSection.ts b/packages/twenty-e2e-testing/lib/pom/settings/rolesSection.ts
index 7e76a717d67..16d8fbc3a9f 100644
--- a/packages/twenty-e2e-testing/lib/pom/settings/rolesSection.ts
+++ b/packages/twenty-e2e-testing/lib/pom/settings/rolesSection.ts
@@ -8,7 +8,10 @@ export class RolesSection {
constructor(page: Page) {
this.page = page;
this.createRoleButton = page.getByRole('button', { name: 'Create Role' });
- this.defaultRoleDropdown = page.getByTestId('tooltip');
+ this.defaultRoleDropdown = page
+ .getByText('Set a default for this workspace', { exact: true })
+ .locator('xpath=../../..')
+ .getByRole('button');
}
async clickCreateRoleButton() {
@@ -17,6 +20,6 @@ export class RolesSection {
async selectDefaultRole(role: string) {
await this.defaultRoleDropdown.click();
- await this.page.getByTestId('tooltip').getByText(role).click();
+ await this.page.getByText(role, { exact: true }).click();
}
}
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md
index 147bd9c5d94..0f2968bc262 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md
@@ -6,6 +6,8 @@ component stories. Each fixture has React and Preact stories built with
Preact stories need Preact 11, which passes `ref` to function components as a
regular prop like React 19. Preact 10 hands that ref to the component instance,
so Dropdown-based popups never open there.
+Typography composition checks constrained text, explicit links, semantic elements, refs and native focus handlers in both runtimes. Overflow tooltip popup acceptance still depends on renderer portal and geometry support.
+
Scenarios share their checks between runtimes where behavior matches. The story
file contains the metadata and named entries; `utils/` holds the story factory,
shared assertions, render checks, interaction checks, and known-failure
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-typography-gallery.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-typography-gallery.front-component.tsx
index 48495812686..79722546962 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-typography-gallery.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-typography-gallery.front-component.tsx
@@ -2,6 +2,7 @@ import { useState } from 'react';
import 'twenty-ui/style.css';
import { defineFrontComponent } from 'twenty-sdk/define';
import { Section } from 'twenty-ui/components/layout';
+import { TypographyCompositionExample } from './typography-composition-example';
import { VisuallyHiddenExample } from './visually-hidden-example';
import { Button } from 'twenty-ui/primitives/input';
import {
@@ -37,6 +38,7 @@ const SectionExample = () => {
};
const TYPOGRAPHY_ENTRIES: GalleryEntry[] = [
+ { name: 'Typography composition', node: <TypographyCompositionExample /> },
{
name: 'Shortcut',
node: (
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/typography-composition-example.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/typography-composition-example.tsx
new file mode 100644
index 00000000000..9b196a6791b
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/typography-composition-example.tsx
@@ -0,0 +1,54 @@
+import { useState } from 'react';
+import {
+ OverflowingTextWithTooltip,
+ Text,
+ type OverflowingTextWithTooltipProps,
+ type TextProps,
+} from 'twenty-ui/primitives/typography';
+
+const OVERFLOW_PROPS = {
+ text: 'https://twenty.com/developers/typography-composition',
+ tooltipDelay: 0,
+ style: { width: 160, display: 'block' },
+} satisfies OverflowingTextWithTooltipProps;
+
+const TEXT_PROPS = {
+ lineClamp: 2,
+ style: { width: 160 },
+} satisfies TextProps;
+
+export const TypographyCompositionExample = () => {
+ const [activations, setActivations] = useState(0);
+
+ return (
+ <>
+ <Text
+ lineClamp={TEXT_PROPS.lineClamp}
+ style={TEXT_PROPS.style}
+ render={<p />}
+ title="Clamped paragraph"
+ >
+ Caller-owned text spans several lines and keeps its semantic paragraph
+ element in the renderer.
+ </Text>
+ <OverflowingTextWithTooltip
+ text={OVERFLOW_PROPS.text}
+ tooltipDelay={OVERFLOW_PROPS.tooltipDelay}
+ style={OVERFLOW_PROPS.style}
+ render={<a href="#typography" aria-label="Typography documentation" />}
+ aria-label="Typography documentation"
+ ref={(element) => {
+ element?.setAttribute('data-ref-target', 'typography-link');
+ }}
+ onFocus={() => {
+ setActivations((count) => count + 1);
+ }}
+ />
+ <OverflowingTextWithTooltip
+ text="https://twenty.com"
+ aria-label="Plain URL"
+ />
+ <Text aria-label="Typography link focuses">{activations}</Text>
+ </>
+ );
+};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/typographyTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/typographyTest.ts
index 67b3708036a..36e01ac7510 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/typographyTest.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/typographyTest.ts
@@ -6,6 +6,23 @@ import { galleryRenderTest } from '@/__stories__/twenty-ui-gallery/utils/gallery
export const typographyTest: TwentyUiGalleryPlayFunction = async (context) => {
await galleryRenderTest(context);
const canvas = within(context.canvasElement);
+ const paragraph = canvas.getByTitle('Clamped paragraph');
+ expect(paragraph.tagName).toBe('P');
+ expect(getComputedStyle(paragraph).webkitLineClamp).toBe('2');
+ expect(paragraph.scrollHeight).toBeGreaterThan(paragraph.clientHeight);
+ const plainUrl = canvas.getByLabelText('Plain URL');
+ expect(plainUrl.querySelector('a')).toBeNull();
+ const link = canvas.getByRole('link', { name: 'Typography documentation' });
+ expect(link).toHaveAttribute('data-ref-target', 'typography-link');
+ expect(link.tagName).toBe('A');
+ expect(link.scrollWidth).toBeGreaterThan(link.clientWidth);
+ await userEvent.tab();
+ await waitFor(() =>
+ expect(canvas.getByLabelText('Typography link focuses')).toHaveTextContent(
+ '1',
+ ),
+ );
+ expect(link).toHaveFocus();
await expect(
canvas.getByRole('heading', { level: 1, name: 'Heading 1' }),
diff --git a/packages/twenty-front/src/modules/activities/tasks/components/TaskRow.tsx b/packages/twenty-front/src/modules/activities/tasks/components/TaskRow.tsx
index 882c945260f..c26e8b5b879 100644
--- a/packages/twenty-front/src/modules/activities/tasks/components/TaskRow.tsx
+++ b/packages/twenty-front/src/modules/activities/tasks/components/TaskRow.tsx
@@ -1,6 +1,7 @@
import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
+import { LinkifiedText } from '@/ui/field/display/components/LinkifiedText/LinkifiedText';
import { getActivitySummary } from '@/activities/utils/getActivitySummary';
import { beautifyExactDate, hasDatePassed } from '~/utils/date-utils';
@@ -131,7 +132,10 @@ export const TaskRow = ({ task }: { task: Task }) => {
{task.title || <StyledPlaceholder>{t`Task title`}</StyledPlaceholder>}
</StyledTaskTitle>
<StyledTaskBody>
- <OverflowingTextWithTooltip text={body} />
+ <OverflowingTextWithTooltip
+ text={<LinkifiedText text={body} />}
+ tooltipContent={body}
+ />
</StyledTaskBody>
</StyledLeftSideContainer>
<StyledRightSideContainer>
diff --git a/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCellContainer.tsx b/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCellContainer.tsx
index 6906eb6fcfa..bcfdd974ad8 100644
--- a/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCellContainer.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCellContainer.tsx
@@ -122,10 +122,7 @@ export const RecordInlineCellContainer = () => {
label={label}
description={fieldDefinition?.metadata?.description}
fallback={
- <OverflowingTextWithTooltip
- text={label}
- displayedMaxRows={1}
- />
+ <OverflowingTextWithTooltip text={label} lineClamp={1} />
}
/>
</StyledLabelContainer>
diff --git a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/internal/LinkifiedText/LinkifiedText.tsx b/packages/twenty-front/src/modules/ui/field/display/components/LinkifiedText/LinkifiedText.tsx
similarity index 63%
rename from packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/internal/LinkifiedText/LinkifiedText.tsx
rename to packages/twenty-front/src/modules/ui/field/display/components/LinkifiedText/LinkifiedText.tsx
index 26e746fd9cd..212afbe6f1b 100644
--- a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/internal/LinkifiedText/LinkifiedText.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/LinkifiedText/LinkifiedText.tsx
@@ -1,9 +1,17 @@
import { isNonEmptyString } from '@sniptt/guards';
-import { getSafeUrl } from '@ui/utilities/utils/getSafeUrl';
+import { styled } from '@linaria/react';
+import { getSafeUrl } from 'twenty-shared/utils';
import { linkifyText } from './linkifyText';
-import styles from './LinkifiedText.module.scss';
+const StyledLink = styled.a`
+ color: var(--t-color-blue);
+ text-decoration: underline;
+
+ &:hover {
+ text-decoration-color: var(--t-color-blue);
+ }
+`;
type LinkifiedTextProps = {
text: string;
@@ -18,16 +26,15 @@ export const LinkifiedText = ({ text }: LinkifiedTextProps) => {
<>
{linkifyText(text).map((part, index) =>
part.type === 'link' ? (
- <a
+ <StyledLink
key={index}
- className={styles.link}
href={getSafeUrl(part.content)}
target="_blank"
rel="noopener noreferrer"
- onClick={(e) => e.stopPropagation()}
+ onClick={(event) => event.stopPropagation()}
>
{part.content}
- </a>
+ </StyledLink>
) : (
part.content
),
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/LinkifiedText/__tests__/LinkifiedText.test.tsx b/packages/twenty-front/src/modules/ui/field/display/components/LinkifiedText/__tests__/LinkifiedText.test.tsx
new file mode 100644
index 00000000000..19254774a0d
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/field/display/components/LinkifiedText/__tests__/LinkifiedText.test.tsx
@@ -0,0 +1,24 @@
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+
+import { LinkifiedText } from '@/ui/field/display/components/LinkifiedText/LinkifiedText';
+
+it('keeps field URL navigation explicit and separate from its row action', async () => {
+ const user = userEvent.setup();
+ const onClick = jest.fn();
+
+ render(
+ <div onClick={onClick}>
+ <LinkifiedText text="Read https://twenty.com/docs today" />
+ </div>,
+ );
+
+ const link = screen.getByRole('link', { name: 'https://twenty.com/docs' });
+ expect(link).toHaveAttribute('href', 'https://twenty.com/docs');
+ expect(link).toHaveAttribute('target', '_blank');
+ expect(link).toHaveAttribute('rel', 'noopener noreferrer');
+
+ await user.click(link);
+
+ expect(onClick).not.toHaveBeenCalled();
+});
diff --git a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/internal/LinkifiedText/__tests__/linkifyText.test.ts b/packages/twenty-front/src/modules/ui/field/display/components/LinkifiedText/__tests__/linkifyText.test.ts
similarity index 95%
rename from packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/internal/LinkifiedText/__tests__/linkifyText.test.ts
rename to packages/twenty-front/src/modules/ui/field/display/components/LinkifiedText/__tests__/linkifyText.test.ts
index 3548dae5670..c9492f51bd3 100644
--- a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/internal/LinkifiedText/__tests__/linkifyText.test.ts
+++ b/packages/twenty-front/src/modules/ui/field/display/components/LinkifiedText/__tests__/linkifyText.test.ts
@@ -1,4 +1,4 @@
-import { linkifyText } from '../linkifyText';
+import { linkifyText } from '@/ui/field/display/components/LinkifiedText/linkifyText';
describe('linkifyText', () => {
it('splits text around a URL into text and link segments', () => {
diff --git a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/internal/LinkifiedText/linkifyText.ts b/packages/twenty-front/src/modules/ui/field/display/components/LinkifiedText/linkifyText.ts
similarity index 91%
rename from packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/internal/LinkifiedText/linkifyText.ts
rename to packages/twenty-front/src/modules/ui/field/display/components/LinkifiedText/linkifyText.ts
index bc055d88dd2..ed4041d2d4f 100644
--- a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/internal/LinkifiedText/linkifyText.ts
+++ b/packages/twenty-front/src/modules/ui/field/display/components/LinkifiedText/linkifyText.ts
@@ -10,8 +10,7 @@ export const linkifyText = (text: string): LinkifyMatch[] => {
let lastIndex = 0;
for (const match of text.matchAll(URL_REGEX)) {
- const url = match[0];
- const index = match.index;
+ const { 0: url, index } = match;
if (index > lastIndex) {
parts.push({ type: 'text', content: text.slice(lastIndex, index) });
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/TextDisplay/TextDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/TextDisplay/TextDisplay.tsx
index 503d751379c..960a6b4044a 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/TextDisplay/TextDisplay.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/TextDisplay/TextDisplay.tsx
@@ -1,8 +1,10 @@
import { css } from '@linaria/core';
import { isUndefined } from '@sniptt/guards';
import { clsx } from 'clsx';
+import { useMemo } from 'react';
import { OverflowingTextWithTooltip } from 'twenty-ui/primitives/typography';
+import { LinkifiedText } from '@/ui/field/display/components/LinkifiedText/LinkifiedText';
const styles = {
container: css`
@@ -25,13 +27,15 @@ type TextDisplayProps = {
};
export const TextDisplay = ({ text, displayedMaxRows }: TextDisplayProps) => {
+ const linkifiedText = useMemo(() => <LinkifiedText text={text} />, [text]);
const fixHeight = isUndefined(displayedMaxRows) || displayedMaxRows === 1;
return (
<div className={clsx(styles.container, fixHeight && styles.fixHeight)}>
<OverflowingTextWithTooltip
- text={text}
- displayedMaxRows={displayedMaxRows}
+ text={linkifiedText}
+ tooltipContent={text}
+ lineClamp={displayedMaxRows}
isTooltipMultiline={true}
/>
</div>
diff --git a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationRegistrationRedirectURIsTable.tsx b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationRegistrationRedirectURIsTable.tsx
index 708074e8a8d..c379d180079 100644
--- a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationRegistrationRedirectURIsTable.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationRegistrationRedirectURIsTable.tsx
@@ -1,3 +1,4 @@
+import { LinkifiedText } from '@/ui/field/display/components/LinkifiedText/LinkifiedText';
import { Table } from '@/ui/layout/table/components/Table';
import { TableBody } from '@/ui/layout/table/components/TableBody';
import { TableCell } from '@/ui/layout/table/components/TableCell';
@@ -48,7 +49,10 @@ export const SettingsApplicationRegistrationRedirectURIsTable = ({
mobileGridAutoColumns="1fr 20px"
>
<TableCell color={themeCssVariables.font.color.primary}>
- <OverflowingTextWithTooltip text={redirectUri} />
+ <OverflowingTextWithTooltip
+ text={<LinkifiedText text={redirectUri} />}
+ tooltipContent={redirectUri}
+ />
</TableCell>
<TableCell align="right">
diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.ts
index 99a5bc0c39a..9d6bbf12c3a 100644
--- a/packages/twenty-ui/docs/components.ts
+++ b/packages/twenty-ui/docs/components.ts
@@ -46,6 +46,7 @@ import { COLOR_SAMPLE_PROP_DESCRIPTIONS } from './colorSamplePropDescriptions';
import { DIALOG_POPUP_PROP_DESCRIPTIONS } from './dialogPopupPropDescriptions';
import { DIALOG_TITLE_PROP_DESCRIPTIONS } from './dialogTitlePropDescriptions';
import { DROPDOWN_PART_PROP_DESCRIPTIONS } from './dropdownPartPropDescriptions';
+import { TEXT_PROP_DESCRIPTIONS } from './textPropDescriptions';
import { HEADING_PROP_DESCRIPTIONS } from './headingPropDescriptions';
import { SEPARATOR_PROP_DESCRIPTIONS } from './separatorPropDescriptions';
import { ICON_BUTTON_PROP_DESCRIPTIONS } from './iconButtonPropDescriptions';
@@ -484,6 +485,7 @@ export const DOCUMENTED_COMPONENTS = [
source: 'primitives/typography/Text/Text.tsx',
entryPoint: 'twenty-ui/primitives/typography',
slug: 'typography/text',
+ propDescriptions: TEXT_PROP_DESCRIPTIONS,
},
{
name: 'Avatar',
diff --git a/packages/twenty-ui/docs/overflowingTextWithTooltipPropDescriptions.ts b/packages/twenty-ui/docs/overflowingTextWithTooltipPropDescriptions.ts
index 6df820d6185..87e2cb037f0 100644
--- a/packages/twenty-ui/docs/overflowingTextWithTooltipPropDescriptions.ts
+++ b/packages/twenty-ui/docs/overflowingTextWithTooltipPropDescriptions.ts
@@ -1,19 +1,19 @@
-import { type ComponentProps } from 'react';
-
-import { type OverflowingTextWithTooltip } from '../src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip';
+import { type OverflowingTextWithTooltipProps } from '../src/primitives/typography/OverflowingTextWithTooltip/types/OverflowingTextWithTooltipProps';
export const OVERFLOWING_TEXT_WITH_TOOLTIP_PROP_DESCRIPTIONS = {
- text: 'Text or React content to truncate. Non-string React content requires `tooltipContent`.',
+ text: 'Caller-owned text or React content. Non-string content requires `tooltipContent`. URLs stay plain text.',
tooltipContent:
- 'Plain text displayed in the tooltip. Defaults to `text` when it is a nonempty string.',
- size: 'Small inherited text sizing or the large fixed-height treatment.',
+ 'Plain text displayed in the tooltip. Defaults to nonempty string `text`.',
+ truncate:
+ 'Single-line ellipsis by default. Set false to wrap. Cannot be combined with `lineClamp`.',
+ lineClamp:
+ 'Positive integer limiting visible lines, matching Text. Cannot be combined with `truncate`.',
+ render:
+ 'Replaces the default div. Native props, styles, handlers and ref target the displayed text, not the popup.',
isTooltipMultiline: 'Preserves whitespace and line breaks in the tooltip.',
- displayedMaxRows:
- 'Maximum displayed rows. Omit for single-line truncation; use a positive integer for multiline text.',
tooltipDelay: 'Hover delay in milliseconds.',
tooltipPlace: 'Preferred side of the tooltip.',
alwaysShowTooltip: 'Allows the tooltip even when the text is not truncated.',
- isFocusable: 'Adds a tab stop and opens the tooltip on focus or click.',
-} satisfies Partial<
- Record<keyof ComponentProps<typeof OverflowingTextWithTooltip>, string>
->;
+ isFocusable:
+ 'Adds an optional tab stop. Native tabIndex and focusable render elements also open the tooltip on focus.',
+} satisfies Partial<Record<keyof OverflowingTextWithTooltipProps, string>>;
diff --git a/packages/twenty-ui/docs/public-exports.json b/packages/twenty-ui/docs/public-exports.json
index 454ed5d91c0..0fe03e938cc 100644
--- a/packages/twenty-ui/docs/public-exports.json
+++ b/packages/twenty-ui/docs/public-exports.json
@@ -959,9 +959,11 @@
},
"types": {
"HeadingProps": "primitives/typography/Heading/types/HeadingProps",
+ "OverflowingTextWithTooltipProps": "primitives/typography/OverflowingTextWithTooltip/types/OverflowingTextWithTooltipProps",
"ShortcutDefinition": "primitives/typography/Shortcut/types/ShortcutDefinition",
"ShortcutFormatOptions": "primitives/typography/Shortcut/types/ShortcutFormatOptions",
- "ShortcutProps": "primitives/typography/Shortcut/types/ShortcutProps"
+ "ShortcutProps": "primitives/typography/Shortcut/types/ShortcutProps",
+ "TextProps": "primitives/typography/Text/types/TextProps"
}
},
"styles": {
diff --git a/packages/twenty-ui/docs/textPropDescriptions.ts b/packages/twenty-ui/docs/textPropDescriptions.ts
new file mode 100644
index 00000000000..731ed8141f2
--- /dev/null
+++ b/packages/twenty-ui/docs/textPropDescriptions.ts
@@ -0,0 +1,10 @@
+import { type TextProps } from '../src/primitives/typography/Text/types/TextProps';
+
+export const TEXT_PROP_DESCRIPTIONS = {
+ truncate:
+ 'Truncates one line with an ellipsis. Cannot be combined with `lineClamp`.',
+ lineClamp:
+ 'Positive integer limiting the number of visible lines. Cannot be combined with `truncate`.',
+ render:
+ 'Replaces the default div. Native props and the ref target the rendered text element.',
+} satisfies Partial<Record<keyof TextProps, string>>;
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index 0da07ee22d1..174af89d11d 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -1473,19 +1473,12 @@
"defaultValue": null,
"description": "Allows the tooltip even when the text is not truncated."
},
- {
- "name": "displayedMaxRows",
- "type": "number",
- "required": false,
- "defaultValue": null,
- "description": "Maximum displayed rows. Omit for single-line truncation; use a positive integer for multiline text."
- },
{
"name": "isFocusable",
"type": "boolean",
"required": false,
"defaultValue": null,
- "description": "Adds a tab stop and opens the tooltip on focus or click."
+ "description": "Adds an optional tab stop. Native tabIndex and focusable render elements also open the tooltip on focus."
},
{
"name": "isTooltipMultiline",
@@ -1495,25 +1488,32 @@
"description": "Preserves whitespace and line breaks in the tooltip."
},
{
- "name": "size",
- "type": "\"large\" | \"small\"",
+ "name": "lineClamp",
+ "type": "number",
"required": false,
"defaultValue": null,
- "description": "Small inherited text sizing or the large fixed-height treatment."
+ "description": "Positive integer limiting visible lines, matching Text. Cannot be combined with `truncate`."
+ },
+ {
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Replaces the default div. Native props, styles, handlers and ref target the displayed text, not the popup."
},
{
"name": "text",
"type": "string | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<...> | null | undefined",
"required": true,
"defaultValue": null,
- "description": "Text or React content to truncate. Non-string React content requires `tooltipContent`."
+ "description": "Caller-owned text or React content. Non-string content requires `tooltipContent`. URLs stay plain text."
},
{
"name": "tooltipContent",
"type": "string",
"required": false,
"defaultValue": null,
- "description": "Plain text displayed in the tooltip. Defaults to `text` when it is a nonempty string."
+ "description": "Plain text displayed in the tooltip. Defaults to nonempty string `text`."
},
{
"name": "tooltipDelay",
@@ -1528,6 +1528,13 @@
"required": false,
"defaultValue": null,
"description": "Preferred side of the tooltip."
+ },
+ {
+ "name": "truncate",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": null,
+ "description": "Single-line ellipsis by default. Set false to wrap. Cannot be combined with `lineClamp`."
}
]
},
@@ -8029,21 +8036,21 @@
"type": "number",
"required": false,
"defaultValue": null,
- "description": "Maximum number of lines before the text is truncated with an ellipsis.\nCannot be combined with `truncate`."
+ "description": "Positive integer limiting the number of visible lines. Cannot be combined with `truncate`."
},
{
"name": "render",
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}>",
"required": false,
"defaultValue": null,
- "description": "Allows you to replace the component's HTML element\nwith a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
+ "description": "Replaces the default div. Native props and the ref target the rendered text element."
},
{
"name": "truncate",
"type": "boolean",
"required": false,
"defaultValue": null,
- "description": "Truncates overflowing text on one line with an ellipsis. Cannot be\ncombined with `lineClamp`."
+ "description": "Truncates one line with an ellipsis. Cannot be combined with `lineClamp`."
}
]
},
diff --git a/packages/twenty-ui/src/components/layout/Section/internal/SectionHeader.tsx b/packages/twenty-ui/src/components/layout/Section/internal/SectionHeader.tsx
index 8cdcb74c5be..d1ac616ab7c 100644
--- a/packages/twenty-ui/src/components/layout/Section/internal/SectionHeader.tsx
+++ b/packages/twenty-ui/src/components/layout/Section/internal/SectionHeader.tsx
@@ -56,7 +56,7 @@ export const SectionHeader = ({
{isString(description) ? (
<OverflowingTextWithTooltip
text={description}
- displayedMaxRows={descriptionLineClamp}
+ lineClamp={descriptionLineClamp}
isTooltipMultiline
isFocusable
/>
diff --git a/packages/twenty-ui/src/primitives/data-display/Chip/Chip.tsx b/packages/twenty-ui/src/primitives/data-display/Chip/Chip.tsx
index 2f4e72c537b..1e69c08efc6 100644
--- a/packages/twenty-ui/src/primitives/data-display/Chip/Chip.tsx
+++ b/packages/twenty-ui/src/primitives/data-display/Chip/Chip.tsx
@@ -9,6 +9,8 @@ import { isDefined } from '@ui/utilities/utils/isDefined';
import styles from './Chip.module.scss';
import { type ChipProps } from './types/ChipProps';
+const MEDIUM_LABEL_STYLE: CSSProperties = { height: 'var(--t-spacing-4)' };
+
export const Chip = ({
children,
size = 'sm',
@@ -70,7 +72,7 @@ export const Chip = ({
(hasContent ? (
typeof children === 'string' ? (
<OverflowingTextWithTooltip
- size={size === 'md' ? 'large' : 'small'}
+ style={size === 'md' ? MEDIUM_LABEL_STYLE : undefined}
text={children}
tooltipContent={tooltipLabel}
tooltipPlace={tooltipPlace}
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/__tests__/ListItem.test.tsx b/packages/twenty-ui/src/primitives/navigation/ListItem/__tests__/ListItem.test.tsx
index 06a452cdd9a..ce07d6f9adc 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/__tests__/ListItem.test.tsx
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/__tests__/ListItem.test.tsx
@@ -68,7 +68,9 @@ describe('ListItem clicks', () => {
});
describe('ListItem content', () => {
- it('gives a text label a tooltip and leaves other content untouched', () => {
+ it('gives a truncated text label a tooltip and leaves other content untouched', async () => {
+ const user = userEvent.setup();
+
render(
<>
<ListItem>Rename</ListItem>
@@ -78,10 +80,16 @@ describe('ListItem content', () => {
</>,
);
- expect(screen.getByText('Rename')).toHaveAttribute(
- 'data-testid',
- 'tooltip',
- );
+ const label = screen.getByText('Rename');
+
+ Object.defineProperties(label, {
+ clientWidth: { value: 40 },
+ scrollWidth: { value: 80 },
+ });
+
+ await user.hover(label);
+
+ expect(await screen.findByRole('tooltip')).toHaveTextContent('Rename');
expect(screen.getByTestId('custom-label')).toBeInTheDocument();
});
});
diff --git a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.module.scss b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.module.scss
index c17c9a02d21..a870d8a69f0 100644
--- a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.module.scss
+++ b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.module.scss
@@ -32,10 +32,6 @@
}
}
-.large {
- height: var(--t-spacing-4);
-}
-
.multilineTooltip {
font-family: inherit;
white-space: pre-wrap;
diff --git a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.module.scss.d.ts b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.module.scss.d.ts
index 166e6370ea8..9271d748267 100644
--- a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.module.scss.d.ts
+++ b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.module.scss.d.ts
@@ -1,7 +1,6 @@
declare const classNames: {
readonly overflowingMultilineText: 'overflowingMultilineText';
readonly overflowingText: 'overflowingText';
- readonly large: 'large';
readonly multilineTooltip: 'multilineTooltip';
};
export default classNames;
diff --git a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.tsx b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.tsx
index 21b186d24b3..8c4d09d91f5 100644
--- a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.tsx
+++ b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.tsx
@@ -1,48 +1,35 @@
-import { memo, useRef, useState, type MouseEvent, type ReactNode } from 'react';
+import { mergeProps } from '@base-ui/react/merge-props';
+import { useMergedRefs } from '@base-ui/utils/useMergedRefs';
+import { memo, useRef, useState, type MouseEvent } from 'react';
import { isNonEmptyString } from '@sniptt/guards';
import { Tooltip } from '@ui/primitives/surfaces/Tooltip/Tooltip';
import { TooltipBody } from '@ui/primitives/surfaces/Tooltip/internal/TooltipBody';
-import { type TooltipSide } from '@ui/primitives/surfaces/Tooltip/types/TooltipSide';
import { Text } from '@ui/primitives/typography/Text/Text';
-import { LinkifiedText } from './internal/LinkifiedText/LinkifiedText';
+import { type OverflowingTextWithTooltipProps } from './types/OverflowingTextWithTooltipProps';
import { isDefined } from '@ui/utilities/utils/isDefined';
import { clsx } from 'clsx';
import styles from './OverflowingTextWithTooltip.module.scss';
-type OverflowingTextWithTooltipProps = {
- size?: 'large' | 'small';
- isTooltipMultiline?: boolean;
- displayedMaxRows?: number;
- tooltipDelay?: number;
- tooltipPlace?: TooltipSide;
- alwaysShowTooltip?: boolean;
- isFocusable?: boolean;
-} & (
- | {
- text: string | null | undefined;
- tooltipContent?: string;
- }
- | {
- text: Exclude<ReactNode, string | null | undefined>;
- tooltipContent: string;
- }
-);
-
export const OverflowingTextWithTooltip = memo(
function OverflowingTextWithTooltip({
- size = 'small',
text,
isTooltipMultiline,
- displayedMaxRows,
+ truncate,
+ lineClamp,
tooltipContent,
tooltipDelay = 500,
tooltipPlace = 'bottom',
alwaysShowTooltip = false,
isFocusable = false,
+ render,
+ ref,
+ className,
+ ...props
}: OverflowingTextWithTooltipProps) {
const textRef = useRef<HTMLDivElement>(null);
+ const mergedRef = useMergedRefs(textRef, ref);
const [isTitleOverflowing, setIsTitleOverflowing] = useState(false);
const [isTooltipOpen, setIsTooltipOpen] = useState(false);
@@ -71,11 +58,6 @@ export const OverflowingTextWithTooltip = memo(
setIsTooltipOpen(isOverflowing || alwaysShowTooltip);
};
- const handleTextClick = () => {
- textRef.current?.focus();
- handleOpenChange(true);
- };
-
const handleTooltipClick = (event: MouseEvent<HTMLDivElement>) => {
event.stopPropagation();
event.preventDefault();
@@ -87,7 +69,7 @@ export const OverflowingTextWithTooltip = memo(
? text
: null;
- const isMultiline = isDefined(displayedMaxRows);
+ const isMultiline = isDefined(lineClamp);
return (
<Tooltip.Root
@@ -97,8 +79,7 @@ export const OverflowingTextWithTooltip = memo(
const shouldKeepTooltipOpen =
!open &&
eventDetails.reason === 'trigger-hover' &&
- isFocusable &&
- document.activeElement === textRef.current;
+ textRef.current?.contains(document.activeElement);
if (shouldKeepTooltipOpen) {
eventDetails.cancel();
@@ -118,23 +99,27 @@ export const OverflowingTextWithTooltip = memo(
render={
<Text
{...(isMultiline
- ? { lineClamp: displayedMaxRows || 1 }
- : { truncate: true })}
- data-testid="tooltip"
+ ? { lineClamp }
+ : { truncate: truncate ?? true })}
data-content-overflowing={isTitleOverflowing ? '' : undefined}
className={clsx(
isMultiline
? styles.overflowingMultilineText
: styles.overflowingText,
- size === 'large' && styles.large,
+ className,
+ )}
+ render={render}
+ ref={mergedRef}
+ {...mergeProps<'div'>(
+ {
+ tabIndex: isFocusable ? 0 : undefined,
+ onPointerEnter: updateOverflowState,
+ onFocus: () => handleOpenChange(true),
+ },
+ props,
)}
- ref={textRef}
- tabIndex={isFocusable ? 0 : undefined}
- onPointerEnter={updateOverflowState}
- onFocus={isFocusable ? () => handleOpenChange(true) : undefined}
- onClick={isFocusable ? handleTextClick : undefined}
>
- {isNonEmptyString(text) ? <LinkifiedText text={text} /> : text}
+ {text}
</Text>
}
/>
diff --git a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__stories__/OverflowTextWithTooltip.stories.tsx b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__stories__/OverflowTextWithTooltip.stories.tsx
index 7026d6c2153..3e7590936df 100644
--- a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__stories__/OverflowTextWithTooltip.stories.tsx
+++ b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__stories__/OverflowTextWithTooltip.stories.tsx
@@ -1,6 +1,8 @@
import { type Meta, type StoryObj } from '@storybook/react-vite';
import { expect, userEvent, waitFor, within } from 'storybook/test';
+import { Text } from '@ui/primitives/typography/Text/Text';
+import { Button } from '@ui/primitives/input/Button/Button';
import { ComponentDecorator } from '@ui/testing';
import { OverflowingTextWithTooltip } from '../OverflowingTextWithTooltip';
@@ -11,6 +13,10 @@ const longText =
const meta: Meta<typeof OverflowingTextWithTooltip> = {
title: 'UI/Surfaces/OverflowingTextWithTooltip',
component: OverflowingTextWithTooltip,
+ args: { style: { maxWidth: 200 } },
+ render: (args) => (
+ <OverflowingTextWithTooltip {...args} data-testid="overflow-text" />
+ ),
};
export default meta;
@@ -23,11 +29,15 @@ export const SingleLineOverflowing: Story = {
decorators: [ComponentDecorator],
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- const tooltip = await canvas.findByTestId('tooltip');
+ const tooltip = await canvas.findByTestId('overflow-text');
await userEvent.hover(tooltip);
const canvasBody = within(canvasElement.ownerDocument.body);
+ await expect(
+ tooltip.scrollWidth > tooltip.clientWidth ||
+ tooltip.scrollHeight > tooltip.clientHeight,
+ ).toBe(true);
const popup = await canvasBody.findByRole('tooltip');
await waitFor(() => expect(popup).toBeVisible());
@@ -46,7 +56,7 @@ export const SingleLineNotOverflowing: Story = {
decorators: [ComponentDecorator],
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- const tooltip = await canvas.findByTestId('tooltip');
+ const tooltip = await canvas.findByTestId('overflow-text');
await userEvent.hover(tooltip);
},
};
@@ -54,16 +64,20 @@ export const SingleLineNotOverflowing: Story = {
export const MultilineOverflowing: Story = {
args: {
text: longText,
- displayedMaxRows: 2,
+ lineClamp: 2,
},
decorators: [ComponentDecorator],
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- const tooltip = await canvas.findByTestId('tooltip');
+ const tooltip = await canvas.findByTestId('overflow-text');
await userEvent.hover(tooltip);
const canvasBody = within(canvasElement.ownerDocument.body);
+ await expect(
+ tooltip.scrollWidth > tooltip.clientWidth ||
+ tooltip.scrollHeight > tooltip.clientHeight,
+ ).toBe(true);
const popup = await canvasBody.findByRole('tooltip');
await waitFor(() => expect(popup).toBeVisible());
@@ -73,12 +87,12 @@ export const MultilineOverflowing: Story = {
export const MultilineNotOverflowing: Story = {
args: {
text: 'Short',
- displayedMaxRows: 2,
+ lineClamp: 2,
},
decorators: [ComponentDecorator],
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- const tooltip = await canvas.findByTestId('tooltip');
+ const tooltip = await canvas.findByTestId('overflow-text');
await userEvent.hover(tooltip);
},
};
@@ -87,7 +101,10 @@ export const SingleLineWithReactNodeOverflowing: Story = {
args: {
text: (
<>
- {longText} · <strong>Secondary Label</strong>
+ {longText} ·{' '}
+ <Text render={<strong />} style={{ display: 'inline' }}>
+ Secondary Label
+ </Text>
</>
),
tooltipContent: `${longText} · Secondary Label`,
@@ -95,11 +112,15 @@ export const SingleLineWithReactNodeOverflowing: Story = {
decorators: [ComponentDecorator],
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- const tooltip = await canvas.findByTestId('tooltip');
+ const tooltip = await canvas.findByTestId('overflow-text');
await userEvent.hover(tooltip);
const canvasBody = within(canvasElement.ownerDocument.body);
+ await expect(
+ tooltip.scrollWidth > tooltip.clientWidth ||
+ tooltip.scrollHeight > tooltip.clientHeight,
+ ).toBe(true);
const popup = await canvasBody.findByRole('tooltip');
await waitFor(() => expect(popup).toBeVisible());
@@ -110,7 +131,10 @@ export const SingleLineWithReactNodeNotOverflowing: Story = {
args: {
text: (
<>
- A · <strong>B</strong>
+ A ·{' '}
+ <Text render={<strong />} style={{ display: 'inline' }}>
+ B
+ </Text>
</>
),
tooltipContent: 'A · B',
@@ -118,7 +142,7 @@ export const SingleLineWithReactNodeNotOverflowing: Story = {
decorators: [ComponentDecorator],
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- const tooltip = await canvas.findByTestId('tooltip');
+ const tooltip = await canvas.findByTestId('overflow-text');
await userEvent.hover(tooltip);
},
};
@@ -127,20 +151,31 @@ export const MultilineWithReactNodeOverflowing: Story = {
args: {
text: (
<>
- Hello! <i>{longText}</i> · <strong>Important Note</strong>
+ Hello!{' '}
+ <Text render={<i />} style={{ display: 'inline' }}>
+ {longText}
+ </Text>{' '}
+ ·{' '}
+ <Text render={<strong />} style={{ display: 'inline' }}>
+ Important Note
+ </Text>
</>
),
tooltipContent: `Hello! ${longText} · Important Note`,
- displayedMaxRows: 2,
+ lineClamp: 2,
},
decorators: [ComponentDecorator],
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- const tooltip = await canvas.findByTestId('tooltip');
+ const tooltip = await canvas.findByTestId('overflow-text');
await userEvent.hover(tooltip);
const canvasBody = within(canvasElement.ownerDocument.body);
+ await expect(
+ tooltip.scrollWidth > tooltip.clientWidth ||
+ tooltip.scrollHeight > tooltip.clientHeight,
+ ).toBe(true);
const popup = await canvasBody.findByRole('tooltip');
await waitFor(() => expect(popup).toBeVisible());
@@ -151,16 +186,80 @@ export const MultilineWithReactNodeNotOverflowing: Story = {
args: {
text: (
<>
- A · <strong>B</strong>
+ A ·{' '}
+ <Text render={<strong />} style={{ display: 'inline' }}>
+ B
+ </Text>
</>
),
tooltipContent: 'A · B',
- displayedMaxRows: 2,
+ lineClamp: 2,
},
decorators: [ComponentDecorator],
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- const tooltip = await canvas.findByTestId('tooltip');
+ const tooltip = await canvas.findByTestId('overflow-text');
await userEvent.hover(tooltip);
},
};
+
+export const ExplicitLink: Story = {
+ decorators: [ComponentDecorator],
+ args: {
+ text: 'https://twenty.com/developers/long-documentation-path',
+ render: (
+ <a
+ href="https://twenty.com/developers/long-documentation-path"
+ aria-label="Typography documentation"
+ />
+ ),
+ style: { maxWidth: 200, display: 'block' },
+ tooltipDelay: 0,
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const link = canvas.getByRole('link');
+ await expect(canvas.getAllByRole('link')).toHaveLength(1);
+ await expect(link.scrollWidth).toBeGreaterThan(link.clientWidth);
+ await userEvent.tab();
+ await expect(link).toHaveFocus();
+ const body = within(canvasElement.ownerDocument.body);
+ await expect(await body.findByRole('tooltip')).toHaveTextContent(
+ link.textContent ?? '',
+ );
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() =>
+ expect(body.queryByRole('tooltip')).not.toBeInTheDocument(),
+ );
+ await expect(link).toHaveFocus();
+ },
+};
+
+export const Focusable: Story = {
+ decorators: [ComponentDecorator],
+ render: (args) => (
+ <>
+ <OverflowingTextWithTooltip {...args} data-testid="overflow-text" />
+ <Button>Next action</Button>
+ </>
+ ),
+ args: { text: longText, isFocusable: true, tooltipDelay: 0 },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const text = canvas.getByTestId('overflow-text');
+ await userEvent.tab();
+ await expect(text).toHaveFocus();
+ const body = within(canvasElement.ownerDocument.body);
+ await expect(await body.findByRole('tooltip')).toHaveTextContent(longText);
+ await userEvent.hover(text);
+ await userEvent.unhover(text);
+ await waitFor(() => expect(body.getByRole('tooltip')).toBeVisible());
+ await userEvent.tab();
+ await expect(
+ canvas.getByRole('button', { name: 'Next action' }),
+ ).toHaveFocus();
+ await waitFor(() =>
+ expect(body.queryByRole('tooltip')).not.toBeInTheDocument(),
+ );
+ },
+};
diff --git a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__tests__/OverflowingTextWithTooltip.test.tsx b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__tests__/OverflowingTextWithTooltip.test.tsx
index 33a21165a19..688b236724f 100644
--- a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__tests__/OverflowingTextWithTooltip.test.tsx
+++ b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__tests__/OverflowingTextWithTooltip.test.tsx
@@ -1,6 +1,9 @@
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
-import { describe, expect, it } from 'vitest';
+import { describe, expect, it, vi } from 'vitest';
+import { createRef } from 'react';
+import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
+import styles from '../OverflowingTextWithTooltip.module.scss';
import { Tooltip } from '@ui/primitives/surfaces/Tooltip/Tooltip';
@@ -21,7 +24,119 @@ const setTextDimensions = ({
});
};
+runComponentConformance({
+ name: 'OverflowingTextWithTooltip',
+ element: <OverflowingTextWithTooltip text="Body" />,
+ ownClassName: styles.overflowingText,
+ refInstanceOf: HTMLDivElement,
+});
+
describe('OverflowingTextWithTooltip', () => {
+ it('keeps URL strings plain inside a caller-provided anchor', () => {
+ render(
+ <a href="https://twenty.com">
+ <OverflowingTextWithTooltip text="https://twenty.com" />
+ </a>,
+ );
+
+ expect(screen.getAllByRole('link')).toHaveLength(1);
+ expect(screen.getByRole('link')).toHaveTextContent('https://twenty.com');
+ });
+
+ it('preserves explicit child links and their focus without adding a tab stop', async () => {
+ const user = userEvent.setup();
+ render(
+ <OverflowingTextWithTooltip
+ text={<a href="https://twenty.com">Documentation</a>}
+ tooltipContent="Open the documentation"
+ alwaysShowTooltip
+ tooltipDelay={0}
+ data-testid="text"
+ />,
+ );
+
+ const link = screen.getByRole('link', { name: 'Documentation' });
+ expect(screen.getByTestId('text')).not.toHaveAttribute('tabindex');
+ await user.tab();
+ expect(link).toHaveFocus();
+ expect(await screen.findByRole('tooltip')).toHaveTextContent(
+ 'Open the documentation',
+ );
+ await user.hover(link);
+ await user.unhover(link);
+ expect(screen.getByRole('tooltip')).toBeVisible();
+ await user.keyboard('{Escape}');
+ await waitFor(() =>
+ expect(screen.queryByRole('tooltip')).not.toBeInTheDocument(),
+ );
+ expect(link).toHaveFocus();
+ });
+
+ it('targets the rendered anchor with native props, ref and composed handlers', async () => {
+ const user = userEvent.setup();
+ const ref = createRef<HTMLDivElement>();
+ const onFocus = vi.fn();
+ const onPointerEnter = vi.fn();
+ const onClick = vi.fn((event) => event.preventDefault());
+ render(
+ <OverflowingTextWithTooltip
+ text="Documentation"
+ render={<a href="https://twenty.com" aria-label="Documentation" />}
+ ref={ref}
+ title="Read documentation"
+ onFocus={onFocus}
+ onPointerEnter={onPointerEnter}
+ onClick={onClick}
+ tooltipDelay={0}
+ />,
+ );
+
+ const link = screen.getByRole('link', { name: 'Documentation' });
+ setTextDimensions({ element: link, clientWidth: 80, scrollWidth: 160 });
+ expect(ref.current).toBe(link);
+ expect(link).toHaveAttribute('title', 'Read documentation');
+ await user.tab();
+ expect(onFocus).toHaveBeenCalledOnce();
+ expect(await screen.findByRole('tooltip')).toHaveTextContent(
+ 'Documentation',
+ );
+ await user.click(link);
+ expect(onPointerEnter).toHaveBeenCalled();
+ expect(onClick).toHaveBeenCalledOnce();
+ });
+
+ it('uses caller tabIndex for focus even when the convenience tab stop is off', async () => {
+ const user = userEvent.setup();
+ render(
+ <OverflowingTextWithTooltip
+ text="Keyboard label"
+ tabIndex={0}
+ alwaysShowTooltip
+ />,
+ );
+ const text = screen.getByText('Keyboard label');
+ await user.tab();
+ expect(text).toHaveFocus();
+ expect(await screen.findByRole('tooltip')).toHaveTextContent(
+ 'Keyboard label',
+ );
+ });
+
+ it('does not open without a nonempty tooltip label', async () => {
+ const user = userEvent.setup();
+ render(
+ <OverflowingTextWithTooltip
+ text={<span>Value</span>}
+ tooltipContent=""
+ alwaysShowTooltip
+ isFocusable
+ />,
+ );
+ await user.tab();
+ await user.hover(screen.getByText('Value'));
+ expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
+ });
+
it('lets a parent tooltip open when the nested text fits', async () => {
const user = userEvent.setup();
diff --git a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/internal/LinkifiedText/LinkifiedText.module.scss b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/internal/LinkifiedText/LinkifiedText.module.scss
deleted file mode 100644
index 861a4f33c1e..00000000000
--- a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/internal/LinkifiedText/LinkifiedText.module.scss
+++ /dev/null
@@ -1,8 +0,0 @@
-.link {
- color: var(--t-color-blue);
- text-decoration: underline;
-
- &:hover {
- text-decoration-color: var(--t-color-blue);
- }
-}
diff --git a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/internal/LinkifiedText/LinkifiedText.module.scss.d.ts b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/internal/LinkifiedText/LinkifiedText.module.scss.d.ts
deleted file mode 100644
index 0361a30bb33..00000000000
--- a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/internal/LinkifiedText/LinkifiedText.module.scss.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-declare const classNames: {
- readonly link: 'link';
-};
-export default classNames;
diff --git a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/types/OverflowingTextWithTooltipProps.ts b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/types/OverflowingTextWithTooltipProps.ts
new file mode 100644
index 00000000000..1cc1ae97f68
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/types/OverflowingTextWithTooltipProps.ts
@@ -0,0 +1,26 @@
+import { type useRender } from '@base-ui/react/use-render';
+import { type ReactNode } from 'react';
+
+import { type TooltipSide } from '@ui/primitives/surfaces/Tooltip/types/TooltipSide';
+import { type TextTruncationProps } from '@ui/primitives/typography/Text/internal/TextTruncationProps';
+
+export type OverflowingTextWithTooltipProps = Omit<
+ useRender.ComponentProps<'div'>,
+ 'children'
+> &
+ TextTruncationProps & {
+ isTooltipMultiline?: boolean;
+ tooltipDelay?: number;
+ tooltipPlace?: TooltipSide;
+ alwaysShowTooltip?: boolean;
+ isFocusable?: boolean;
+ } & (
+ | {
+ text: string | null | undefined;
+ tooltipContent?: string;
+ }
+ | {
+ text: Exclude<ReactNode, string | null | undefined>;
+ tooltipContent: string;
+ }
+ );
diff --git a/packages/twenty-ui/src/primitives/typography/Shortcut/__tests__/Shortcut.test.tsx b/packages/twenty-ui/src/primitives/typography/Shortcut/__tests__/Shortcut.test.tsx
new file mode 100644
index 00000000000..e93e6a1cdc0
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/typography/Shortcut/__tests__/Shortcut.test.tsx
@@ -0,0 +1,41 @@
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { createRef } from 'react';
+import { describe, expect, it, vi } from 'vitest';
+
+import { Shortcut } from '../Shortcut';
+
+describe('Shortcut native presentation', () => {
+ it('forwards native span props and ref while keeping formatting explicit', async () => {
+ const user = userEvent.setup();
+ const ref = createRef<HTMLSpanElement>();
+ const onClick = vi.fn();
+ const onKeyDown = vi.fn();
+ render(
+ <Shortcut
+ shortcut={['Mod', 'K']}
+ platform="other"
+ combinationSeparator=" + "
+ variant="text"
+ ref={ref}
+ title="Search hint"
+ className="caller-hint"
+ style={{ marginTop: 7 }}
+ onClick={onClick}
+ onKeyDown={onKeyDown}
+ tabIndex={0}
+ />,
+ );
+ const hint = screen.getByRole('img', { name: 'Control + K' });
+ expect(ref.current).toBe(hint);
+ expect(hint.tagName).toBe('SPAN');
+ expect(hint).toHaveTextContent('Ctrl + K');
+ expect(hint).toHaveClass('caller-hint');
+ expect(hint).toHaveStyle({ marginTop: '7px' });
+ expect(hint).toHaveAttribute('title', 'Search hint');
+ await user.click(hint);
+ await user.keyboard('k');
+ expect(onClick).toHaveBeenCalledOnce();
+ expect(onKeyDown).toHaveBeenCalledOnce();
+ });
+});
diff --git a/packages/twenty-ui/src/primitives/typography/Text/Text.tsx b/packages/twenty-ui/src/primitives/typography/Text/Text.tsx
index 5c0d821bf3c..fd582db208e 100644
--- a/packages/twenty-ui/src/primitives/typography/Text/Text.tsx
+++ b/packages/twenty-ui/src/primitives/typography/Text/Text.tsx
@@ -4,27 +4,9 @@ import { type CSSProperties } from 'react';
import { isDefined } from '@ui/utilities/utils/isDefined';
-import styles from './Text.module.scss';
-
-type TextTruncationProps =
- | {
- /**
- * Truncates overflowing text on one line with an ellipsis. Cannot be
- * combined with `lineClamp`.
- */
- truncate?: boolean;
- lineClamp?: never;
- }
- | {
- truncate?: never;
- /**
- * Maximum number of lines before the text is truncated with an ellipsis.
- * Cannot be combined with `truncate`.
- */
- lineClamp?: number;
- };
+import { type TextProps } from './types/TextProps';
-type TextProps = useRender.ComponentProps<'div'> & TextTruncationProps;
+import styles from './Text.module.scss';
export const Text = ({
render,
diff --git a/packages/twenty-ui/src/primitives/typography/Text/__tests__/Text.test.tsx b/packages/twenty-ui/src/primitives/typography/Text/__tests__/Text.test.tsx
index 2b847448c75..0b6c3978a87 100644
--- a/packages/twenty-ui/src/primitives/typography/Text/__tests__/Text.test.tsx
+++ b/packages/twenty-ui/src/primitives/typography/Text/__tests__/Text.test.tsx
@@ -1,3 +1,6 @@
+import { render, screen } from '@testing-library/react';
+import { describe, expect, it } from 'vitest';
+
import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
import { Text } from '../Text';
@@ -9,3 +12,23 @@ runComponentConformance({
ownClassName: styles.truncate,
refInstanceOf: HTMLDivElement,
});
+
+describe('Text', () => {
+ it('renders caller-owned semantic content without automatic links', () => {
+ render(
+ <Text render={<p />} truncate>
+ https://twenty.com
+ </Text>,
+ );
+ expect(screen.getByText('https://twenty.com').tagName).toBe('P');
+ expect(screen.queryByRole('link')).not.toBeInTheDocument();
+ });
+
+ it.each([0, -1, 1.5, Number.NaN])(
+ 'ignores invalid line limits %s',
+ (lineClamp) => {
+ render(<Text lineClamp={lineClamp}>Description</Text>);
+ expect(screen.getByText('Description')).not.toHaveClass(styles.lineClamp);
+ },
+ );
+});
diff --git a/packages/twenty-ui/src/primitives/typography/Text/internal/TextTruncationProps.ts b/packages/twenty-ui/src/primitives/typography/Text/internal/TextTruncationProps.ts
new file mode 100644
index 00000000000..2489169764b
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/typography/Text/internal/TextTruncationProps.ts
@@ -0,0 +1,3 @@
+export type TextTruncationProps =
+ | { truncate?: boolean; lineClamp?: never }
+ | { truncate?: never; lineClamp?: number };
diff --git a/packages/twenty-ui/src/primitives/typography/Text/types/TextProps.ts b/packages/twenty-ui/src/primitives/typography/Text/types/TextProps.ts
new file mode 100644
index 00000000000..2430b38141f
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/typography/Text/types/TextProps.ts
@@ -0,0 +1,5 @@
+import { type useRender } from '@base-ui/react/use-render';
+
+import { type TextTruncationProps } from '../internal/TextTruncationProps';
+
+export type TextProps = useRender.ComponentProps<'div'> & TextTruncationProps;
diff --git a/packages/twenty-ui/src/primitives/typography/index.ts b/packages/twenty-ui/src/primitives/typography/index.ts
index e89bfa662b4..5951202c013 100644
--- a/packages/twenty-ui/src/primitives/typography/index.ts
+++ b/packages/twenty-ui/src/primitives/typography/index.ts
@@ -10,9 +10,11 @@
export { Heading } from './Heading/Heading';
export type { HeadingProps } from './Heading/types/HeadingProps';
export { OverflowingTextWithTooltip } from './OverflowingTextWithTooltip/OverflowingTextWithTooltip';
+export type { OverflowingTextWithTooltipProps } from './OverflowingTextWithTooltip/types/OverflowingTextWithTooltipProps';
export { formatShortcut } from './Shortcut/formatShortcut';
export { Shortcut } from './Shortcut/Shortcut';
export type { ShortcutDefinition } from './Shortcut/types/ShortcutDefinition';
export type { ShortcutFormatOptions } from './Shortcut/types/ShortcutFormatOptions';
export type { ShortcutProps } from './Shortcut/types/ShortcutProps';
export { Text } from './Text/Text';
+export type { TextProps } from './Text/types/TextProps';