Repository navigation
Tooltip: Limit the popup width and wrap long words - #87918
Conversation
A long label, such as a remove button named after a filename, made the popup as wide as its text, so it widened the page at 320px. Limit the popup to the extra small surface width and to the space Base UI reports in `--available-width`, and wrap long words with `overflow-wrap: anywhere`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: +381 B (0%) Total Size: 8.86 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. chevron opens and closes submenu on touch devices in
|
At 320px the token always wins, so the test passed without the available width part of the rule. At 220px it fails without it.
…lipped The width limit and short label cases pinned a design value and guarded speculative changes. The reflow test now also fails if the label is clipped instead of wrapped.
What?
Follow-up to #86732.
Limits the
@wordpress/uiTooltippopup to 240px, or to the space left in the viewport when that is less, and wraps long words.Why?
A tooltip was as wide as its text. In the Selecting Local Files pattern from #86732, a remove button named after a long filename widened the page to 452px at a 320px viewport. In a right-to-left layout, the same tooltip ran off the screen edge, and part of its text could not be seen. Production tooltips show the same kind of text, such as the filename tooltip in
media-fieldsand truncatedBreadcrumbitems.How?
Two rules on
Tooltip.Popup:max-width: min(var(--available-width), var(--wpds-dimension-surface-width-xs)). Base UI sets--available-widthon the positioner: the space between the trigger and the viewport edge, less the collision padding.Menuand the shared item popup already limit their width this way.overflow-wrap: anywhere, so a word with no break opportunity, such as a filename with underscores, wraps instead of overflowing.Tooltips longer than about 40 characters now wrap at 240px. A
side="left"orside="right"tooltip next to the viewport edge can get narrow, asMenualready does.Alternatives measured in Chromium
overflow-wrap: break-word--available-widthand wrap, no capFixing it in each consumer does not work:
IconButtonrenders its ownTooltip.Popupand exposes only thepositionerslot, so callers cannot style the popup.Testing Instructions
iframe.html?id=design-system-patterns-file-picker-multiple--choose-files&viewMode=story. It is also on the Design System → Patterns → Selecting Local Files page. Make the window about 320px wide.quarterly_financial_report_final_version_reviewed_and_approved_2026.pdf.&globals=direction:rtlto the URL and repeat. On trunk, the tooltip runs off the right edge and its start is cut off. With this PR, it wraps inside the viewport.Testing Instructions for Keyboard
In step 3, press Tab until the remove button has focus. The tooltip opens and wraps the same way.
Screenshots or screencast
Storybook, File Picker Multiple, at 320px. The trunk image is as wide as the page became.
The same story in right-to-left at 320px:
Desktop width and short labels
File Picker Multiple at 1280px, cropped to the right 720px:
Tooltip, Default story, at 1280px:
Use of AI Tools
Claude Code (Claude Opus 5.5) compared the options, wrote the change and its browser tests, and captured the screenshots.
🤖 Generated with Claude Code