Skip to content

feat(Tooltip): maxWidth sets the surface's cap per instance; 300px stays the default - #11452

Draft
nynexman4464 wants to merge 3 commits into
mainfrom
nynexman4464/feat/tooltip-max-width
Draft

nynexman4464 wants to merge 3 commits into
mainfrom
nynexman4464/feat/tooltip-max-width

Conversation

@nynexman4464

@nynexman4464 nynexman4464 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Blocked on owner approval. This amends current component:Tooltip FR1 (the 300 px cap) and adds DEC-2. Classification: novel-human (a new public input).

User need

Some tooltips need more than 300 px:

  • a column heading that would wrap onto three lines;
  • a short formatted value list;
  • a sentence-long reason.

The surface's maxWidth: 300 is set on the inner content box, so nothing a caller passes (a className, a style, or a wrapper inside content) can widen it: a child cannot widen its parent. The only lever today is a theme override, which changes every tooltip in an app.

Problem and solution fit

maxWidth sets the content box's cap per instance. The 300 px default is unchanged, so no existing tooltip moves.

Current specification

component:Tooltip FR1 (current) says the surface is "at most 300 px wide". This PR amends FR1 to "at most maxWidth wide (300 px by default)". It also adds a Maximum width row to Public concepts, and DEC-2 (proposed, pending the owner).

Public delta and caller burden

  • Tooltip and useTooltip take maxWidth?: SizeValue, default 300. It caps the content, padding included. Numbers are treated as pixels and strings are used as-is, the same type and wording as Card, Section, Center, Grid and Stack's maxWidth. A theme cap on the tooltip target also applies, and the narrower cap wins.
  • The caller decides nothing new unless content needs to be wider.
  • Theming is unchanged: the tooltip target still styles the surface.
<Tooltip content="Referrer viewer/viewee pairs percentage" maxWidth={384}>
  <span>Pairs %</span>
</Tooltip>

Design and alternatives

  • Rejected (DEC-2): a theme-only width, which changes every tooltip in the app.
  • Not chosen: width. A tooltip sizes to its content up to a cap, so a cap is the concept being set.
  • Not advertised: a 'none' keyword. No Astryx size prop documents one, and a fixed width serves the one call site that asked for no cap. A string is still used as-is.

Evidence

  • Default path: "caps the surface at 300px by default" checks that the computed max-width is 300px.
  • Configured path: "takes a per-instance maxWidth in pixels or as a CSS length" covers 384 and '24rem'. It fails without the change and passes with it.
  • Unchanged paths: the Tooltip and InfoTip suites pass (6 files, 169 tests).

Scope

Components: Tooltip, useTooltip

  • One capability is added.
  • Unrelated fixes, cleanup, and policy changes were removed or split.
  • Consumer docs, focused tests, and migration evidence ship with the feature.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm exec vitest run --project ui packages/core/src/Tooltip packages/core/src/InfoTip packages/core/src/IconButton: 7 files, 185 tests passed
  • tsc --noEmit (core), pnpm check:knowledge
  • Not run: a real browser. The change is one CSS declaration on the content box, verified in jsdom.

@vercel

vercel Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 16, 2026 8:53pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 13, 2026
@astracat-bot

astracat-bot Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Nov 16, 2026, 9:08 PM UTC

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 13, 2026
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

Current run: The current CI run concluded skipped. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner deciding the Tooltip spec change, and three fixes are needed either way.

This pull request amends the existing Tooltip spec: FR1's fixed 300 px cap becomes a per-instance maxWidth (300 px by default), with a new Maximum width concept and DEC-2. An engineering owner records that decision by commenting /approve-spec <full head SHA> on the pull request; as an engineering owner, the author may record it.

Required fixes:

  • The Tooltip record still lists FR1's default and per-instance maximum width under "Read from source, with no focused test yet" although this pull request adds both tests, so cite them in the FR1 verification row instead.
  • The record's Compatibility class still says "no public prop, default, DOM, or target change" although maxWidth is a new public prop, so state the additive prop there.
  • The description has no ## Writing rubric results section, which every pull request that changes a knowledge record must report, so run the spec-writing rubric over the Tooltip record and add its results.

The default renders exactly as on main, and 384, '12rem' and 'none' size the surface as described in Chromium.

Claims and files checked
  • Claim: Tooltip and useTooltip take maxWidth, the widest the surface grows before wrapping. Verified: Tooltip.tsx:172, useTooltip.tsx:179; Chromium shows a 384 px surface for 384.
  • Claim: a number is pixels and a string is any CSS length such as '24rem' or 'none'. Verified: useTooltip.tsx:992; Chromium shows 192 px for '12rem' and no cap for 'none'.
  • Claim: the default stays 300 px and no existing tooltip moves. Verified: useTooltip.tsx:83; Tooltip.test.tsx:107; the default frame is pixel-identical to the base.
  • Claim: a patch changeset for this feature. Verified: the changeset check passes (non-breaking 0.x changes are patches).
  • Claim: the 300 px cap sits on the inner content box. Verified: useTooltip.tsx:78-85.
  • Claim: no className, style or content wrapper can widen it today. Verified: Tooltip takes no styling props, and a child cannot widen a capped parent.
  • Claim: the only lever today is a theme override, which changes every tooltip. Verified in substance: no per-instance lever exists; a theme's tooltip override styles the outer surface, so only CSS that reaches the inner box raises the cap, and then for every tooltip.
  • Claim: FR1 is amended, a Maximum width row and DEC-2 are added. Verified: Tooltip.spec.md:176, :170, :323.
  • Claim: theming is unchanged. Verified: the tooltip target stays on the layer container (useTooltip.tsx:970); theme builds show no surface change.
  • Claim: the default test checks a computed 300px. Verified: Tooltip.test.tsx:107-115.
  • Claim: the configured test covers 384 and 'none' and fails without the change. Verified: it fails on the base and passes on the head.
  • Claim: the Tooltip, InfoTip and IconButton suites pass (7 files, 185 tests). Verified: rerun at this head.
  • Claim: the core typecheck and the knowledge check pass. Verified: both pass at this head.
  • Claim: no real-browser run, one CSS declaration on the content box. Verified: a Chromium check here confirms the sizes.
  • File .changeset/tooltip-max-width.md: clear.
  • File docs/specs/components/Tooltip/Tooltip.spec.md: stale no-test list (285-286), stale Compatibility class (69-70), repeated sentence (47, non-blocking); the proposed FR1, concept and DEC-2 wait on an owner.
  • File packages/core/src/Tooltip/Tooltip.doc.mjs: clear.
  • File packages/core/src/Tooltip/Tooltip.test.tsx: clear.
  • File packages/core/src/Tooltip/Tooltip.tsx: clear.
  • File packages/core/src/Tooltip/useTooltip.doc.mjs: clear.
  • File packages/core/src/Tooltip/useTooltip.tsx: clear.

Automated review (maintainer link)

| Area | Contract |
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Public contract | `Tooltip` with `content`, `children` or `anchorRef`, `placement` (`above`), `alignment` (`center`), `delay` (200), `hideDelay` (0), `focusTrigger` (`auto`), `touchTrigger` (`auto`), `isEnabled`, `isOpen`, `isDefaultOpen`, `onOpenChange`, and `hasHoverIndication`; target `tooltip`. `useTooltip` takes the same `touchTrigger`, and its return includes imperative `show` and `hide` (FR12). A tooltip pins through `show()` and `hide()` (FR9, FR10); Tooltip has no toggle prop or option, and `component:InfoTip` pins this way. |
| Public contract | `Tooltip` with `content`, `children` or `anchorRef`, `placement` (`above`), `alignment` (`center`), `delay` (200), `hideDelay` (0), `focusTrigger` (`auto`), `touchTrigger` (`auto`), `isEnabled`, `isOpen`, `isDefaultOpen`, `onOpenChange`, `hasHoverIndication`, and `maxWidth` (300 px); target `tooltip`. `useTooltip` takes the same `maxWidth`. `useTooltip` takes the same `touchTrigger`, and its return includes imperative `show` and `hide` (FR12). A tooltip pins through `show()` and `hide()` (FR9, FR10); Tooltip has no toggle prop or option, and `component:InfoTip` pins this way. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: "useTooltip takes the same" now appears twice in a row. One sentence reads better: "useTooltip takes the same touchTrigger and maxWidth, and its return includes imperative show and hide (FR12)."

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner deciding the Tooltip spec change, and four fixes are needed either way.

This pull request amends the existing Tooltip spec: FR1's fixed 300 px cap becomes a per-instance maxWidth (300 px by default), with a new Maximum width concept, its fallbacks and DEC-2. An engineering owner records that decision by commenting /approve-spec <full head SHA> on the pull request; as an engineering owner, the author may record it.

Required fixes:

  • The Tooltip record still lists FR1's default and per-instance maximum width (now also none and the negative-number fallback) under "Read from source, with no focused test yet" although this pull request tests all of them, so cite the two new tests in the FR1 verification row instead.
  • The record's Compatibility class still says "no public prop, default, DOM, or target change" although maxWidth is a new public prop, so state the additive prop there.
  • The description has no ## Writing rubric results section, which every pull request that changes a knowledge record must report, so run the spec-writing rubric over the Tooltip record and add its results.
  • Newly live check: useTooltip.tsx is shared by Button, IconButton, TextInput, Link and other components and grows here, so the description must report the first-load gzip delta on the four reference pages (base against head: docs +179 B, form +177 B, menu +106 B, table +121 B, all under the 0.3 KB limit).

The default renders exactly as on main, and 384, '24rem', 'none' and -5 size the surface as the proposed record says.

Claims and files checked

Review mode: full; reason: spec-record

  • Claim: the change amends FR1 and adds DEC-2, a new public input. Verified: Tooltip.spec.md:176, :323-335.
  • Claim: the cap sits on the inner content box, so no class, style or content wrapper can widen it. Verified: useTooltip.tsx:78-85; Tooltip takes no styling props.
  • Claim: the only lever today is a theme override, which changes every tooltip. Verified in substance: no per-instance lever exists; a theme's tooltip cap reaches only the outer surface (a 600 px cap leaves the content at 300 px), so only CSS that reaches the inner box widens it, for every tooltip.
  • Claim: the default stays 300 px, so no existing tooltip moves. Verified: Tooltip.test.tsx:107; the default frame is pixel-identical to the base.
  • Claim: Tooltip and useTooltip take maxWidth?: number | string, default 300, capping the content with its padding. Verified: Tooltip.tsx:175, useTooltip.tsx:182; padding is included with the documented reset stylesheet (400 px for 384 without it).
  • Claim: a number is pixels, and a negative or non-finite one keeps 300 px. Verified: useTooltip.tsx:969-974; Tooltip.test.tsx:140-145; Chromium shows 300 px for -5.
  • Claim: a string is a CSS max-width value such as '24rem', '50vw' or 'none', and a rejected string uncaps the surface. Verified: Chromium shows 384 px for '24rem', 828 px for 'none' and an uncapped surface for '384'.
  • Claim: a theme cap on the tooltip target also applies and the narrower cap wins. Verified: a 200 px target cap holds maxWidth={384} at 200 px.
  • Claim: callers decide nothing new unless content needs more width, and theming is unchanged. Verified: the target stays on the layer container; theme builds show no surface change.
  • Claim: the default-path test checks a computed 300 px. Verified: Tooltip.test.tsx:107-115.
  • Claim: the configured test covers 384, 'none', '24rem' and -5 and fails without the change. Verified: it fails on the base and passes on the head.
  • Claim: the Tooltip and InfoTip suites pass (6 files, 169 tests). Verified: rerun at this head.
  • Claim: the Tooltip, InfoTip and IconButton suites pass (7 files, 185 tests), with the core typecheck and the knowledge check. Verified: rerun at this head.
  • Claim: no real-browser run; the change is one CSS declaration on the content box. Verified: a Chromium check here confirms the sizes.
  • Claim: one capability, no unrelated changes, docs and tests included, no internal context. Verified: every file serves maxWidth.
  • Claim (changeset): a core patch; Tooltip and useTooltip take maxWidth, a number in pixels or a CSS length such as '24rem' or 'none', default 300 px. Verified: the changeset check passes; 'none' is a max-width keyword rather than a length, a wording point only.
  • File .changeset/tooltip-max-width.md: clear.
  • File docs/specs/components/Tooltip/Tooltip.spec.md: stale no-test list (285-287), stale Compatibility class (69-70), repeated sentence (47, non-blocking); the proposed FR1, concept and DEC-2 wait on an owner.
  • File packages/core/src/Tooltip/Tooltip.doc.mjs: the Chinese entry keeps the earlier wording (non-blocking).
  • File packages/core/src/Tooltip/Tooltip.test.tsx: clear.
  • File packages/core/src/Tooltip/Tooltip.tsx: clear.
  • File packages/core/src/Tooltip/useTooltip.doc.mjs: clear.
  • File packages/core/src/Tooltip/useTooltip.tsx: clear in code; INV10 first-load deltas missing from the description.

Automated review (maintainer link)

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner deciding the Tooltip spec change, and five fixes are needed either way.

This pull request amends the existing Tooltip spec: FR1's fixed 300 px cap becomes a per-instance maxWidth (300 px by default), with a new Maximum width concept and DEC-2. An engineering owner records that decision by commenting /approve-spec <full head SHA> on the pull request; as an engineering owner, the author may record it.

Required fixes:

  • The new Maximum width row says a value the browser rejects is "ignored", but maxWidth={-5} or maxWidth="384" removes the 300 px cap and the surface spreads to the viewport, so state that result or restore a fallback that keeps 300 px.
  • The Tooltip record still lists FR1's default and per-instance maximum width under "Read from source, with no focused test yet" although this pull request tests both, so cite the two new tests in the FR1 verification row instead.
  • The record's Compatibility class still says "no public prop, default, DOM, or target change" although maxWidth is a new public prop, so state the additive prop there.
  • The description has no ## Writing rubric results section, which every pull request that changes a knowledge record must report, so run the spec-writing rubric over the Tooltip record and add its results.
  • maxWidth is an optional feature in a shared hook, so the description must report the first-load gzip delta, base against head, on the reference pages (the Button and IconButton entries grow by about 50 B, under the 0.3 KB limit).

The default renders exactly as on main, and 384, '24rem' and 200 size the surface as proposed.

Claims and files checked

Review mode: full; reason: spec-record

  • Claim: the change amends current FR1 and adds DEC-2, a new public input. Verified: Tooltip.spec.md:176, :323-335.
  • Claim: some tooltips need more than 300 px. Verified in substance: a long column description wraps onto five lines at 300 px in Chromium.
  • Claim: the cap sits on the inner content box, so no class, style or content wrapper can widen it. Verified: useTooltip.tsx:79-86; Tooltip takes no styling props.
  • Claim: the only lever today is a theme override, which changes every tooltip. Verified in substance: no per-instance lever exists, and the tooltip target sits on the layer container (useTooltip.tsx:971), so only app-wide CSS that reaches the inner box widens it.
  • Claim: the default stays 300 px, so no existing tooltip moves. Verified: Tooltip.test.tsx:107; the default frame is pixel-identical to the base.
  • Claim: Tooltip and useTooltip take maxWidth?: SizeValue, default 300, capping the content with its padding. Verified: Tooltip.tsx:173, useTooltip.tsx:180; padding is included through the reset stylesheet's border-box.
  • Claim: numbers are pixels and strings are used as-is, with the same type and wording as Card, Section, Center, Grid and Stack. Verified: each of those props is maxWidth?: SizeValue with that sentence in its JSDoc.
  • Claim: a theme cap on the tooltip target also applies and the narrower cap wins. Verified from the structure: the target is on the layer container and the cap on the inner box.
  • Claim: callers decide nothing new unless content needs more width. Verified, with the caveat that an invalid value silently removes the cap.
  • Claim: theming is unchanged. Verified: the seven theme builds show no surface change.
  • Claim: a 'none' keyword is not advertised, and a string is still used as-is. Verified: useTooltip.tsx:989-992 passes strings through.
  • Claim: the default-path test checks a computed 300 px. Verified: Tooltip.test.tsx:107-115.
  • Claim: the configured test covers 384 and '24rem' and fails without the change. Verified: it fails on the base and passes on the head.
  • Claim: the Tooltip and InfoTip suites pass (6 files, 169 tests). Verified: rerun at this head.
  • Claim: the Tooltip, InfoTip and IconButton suites pass (7 files, 185 tests), with the core typecheck and the knowledge check. Verified: rerun at this head.
  • Claim: no real-browser run; the change is one CSS declaration on the content box. Verified: a Chromium check here confirms the sizes.
  • Claim: one capability, no unrelated changes, docs and tests included, no internal context. Verified: every file serves maxWidth.
  • Claim (changeset): a core patch; Tooltip and useTooltip take maxWidth, numbers in pixels and strings as-is like Card's and Stack's, default 300 px. Verified: Tooltip.tsx:173, Tooltip.test.tsx:107, Card and Stack JSDoc.
  • File .changeset/tooltip-max-width.md: clear.
  • File docs/specs/components/Tooltip/Tooltip.spec.md: the invalid-value row misstates the result (170); stale no-test list (285-286); stale Compatibility class (69-70); repeated sentence (47) and FR1 wording (176), non-blocking; the proposed FR1, concept and DEC-2 wait on an owner.
  • File packages/core/src/Tooltip/Tooltip.doc.mjs: the Chinese entry types the prop number | string instead of SizeValue (non-blocking).
  • File packages/core/src/Tooltip/Tooltip.test.tsx: clear.
  • File packages/core/src/Tooltip/Tooltip.tsx: clear.
  • File packages/core/src/Tooltip/useTooltip.doc.mjs: clear.
  • File packages/core/src/Tooltip/useTooltip.tsx: clear in code; first-load deltas missing from the description.

Automated review (maintainer link)

| ------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | ------- | ------------------- | --------- | ------------------------------------------------------ |
| Focus trigger | `auto`, `always`, `never` | Whether keyboard focus opens the tooltip: on focusable triggers, judged when focus arrives (FR4), always, or never. | Every trigger mode. | `auto` | `component:Tooltip` | Stable | TypeScript rejects other values. |
| Touch trigger | `auto`, `tap`, `none` | Whether it is safe to consume a tap to show the tooltip (DEC-1): `auto` shows it on a tap unless the trigger itself performs an action, a disabled control excepted (FR5); `tap` shows it on every tap; `none` on no tap. | Touch and pen without hover; on a button that pins through `show()`, its click decides taps (FR9). | `auto` | `component:Tooltip` | Stable | TypeScript rejects other values. |
| Maximum width | A number of pixels, or a CSS size used as-is | The widest the surface grows before its content wraps (FR1). | Every trigger mode. | 300 px | `component:Tooltip` | Stable | Not validated: a value the browser rejects is ignored. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This row says a value the browser rejects is "ignored", but in Chromium maxWidth={-5} and maxWidth="384" drop the 300 px cap as well: the surface spreads to 868 px in a 900 px viewport. State the real result ("a value the browser rejects removes the cap"), or restore a fallback that keeps 300 px and state that; spec:AST-002 FR15 asks for prevention, a warning, or a safe documented fallback.

| ID | Invariant | Basis |
| ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| FR1 | The rendered tooltip contains one owned surface, `role="tooltip"`, carrying the `tooltip` target, at most 300 px wide, with the supplied `content` inside; content has no separate target and there is no arrow. | Current source, docs, and tests |
| FR1 | The rendered tooltip contains one owned surface, `role="tooltip"`, carrying the `tooltip` target, its content, padding included, at most `maxWidth` wide (300 px by default; a number is pixels, a string is used as-is). A theme cap on the `tooltip` target also applies, and the narrower cap wins, with the supplied `content` inside; content has no separate target and there is no arrow. | Current source, docs, and tests |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: "the narrower cap wins, with the supplied content inside" now attaches the content to the theme cap. Move "with the supplied content inside" back beside the surface, or split the sentence.

@nynexman4464

Copy link
Copy Markdown
Contributor Author

/approve-spec 2694170

This branch was successfully deployed

1 active deployment
Preview — 26941701 Deployed Nov 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant