Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tooltip-missing-text.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Tooltip: Guard against missing `text` values at runtime when checking whether a tooltip has content.
2 changes: 1 addition & 1 deletion packages/react/src/TooltipV2/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export const Tooltip: ForwardRefExoticComponent<

// Normalize keybindingHint to an array for uniform rendering
const keybindingHints = Array.isArray(keybindingHint) ? keybindingHint : [keybindingHint]
const hasText = Boolean(text.trim())
const hasText = typeof text === 'string' && text.trim().length > 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fair ask, but optional!

const hasContent = hasText || keybindingHints.length > 0

const [calculatedDirection, setCalculatedDirection] = useState<TooltipDirection>(direction)
Expand Down
Loading