Skip to content

fix: display resolved value of 0 in token tooltip#3793

Open
six7 wants to merge 1 commit intomainfrom
fix/tooltip-zero-value
Open

fix: display resolved value of 0 in token tooltip#3793
six7 wants to merge 1 commit intomainfrom
fix/tooltip-zero-value

Conversation

@six7
Copy link
Collaborator

@six7 six7 commented Feb 26, 2026

Summary

Fixes #3776

When a token's resolved value is exactly 0, the tooltip's alias badge was showing a blank value instead of displaying "0".

Root Cause

In AliasBadge.tsx, the expression value || '' was used to provide a fallback. Since 0 is falsy in JavaScript, this treated a valid value of 0 the same as null/undefined, replacing it with an empty string.

Fix

Changed value || '' to value ?? '' (nullish coalescing), which only falls back to '' for null and undefined — not for 0.

Testing

  • Added test tokens with value 0 and an alias referencing them
  • Added explicit test case verifying the resolved value 0 is displayed in the tooltip
  • All 33 tooltip tests pass

@changeset-bot
Copy link

changeset-bot bot commented Feb 26, 2026

🦋 Changeset detected

Latest commit: 8189b2c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tokens-studio/figma-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Feb 26, 2026

⤵️ 📦 ✨ The artifact was successfully created! Want to test it? Download it here 👀 🎁

@github-actions
Copy link
Contributor

github-actions bot commented Feb 26, 2026

Commit SHA:3a29827a5e457d4ddc47fab76ac6438917eb0ec6

Test coverage results 🧪

Code coverage diff between base branch:main and head branch: fix/tooltip-zero-value 
Status File % Stmts % Branch % Funcs % Lines
🟢 total 64.49 (0) 56.97 (0.01) 61.01 (0) 64.85 (0)
🟢 packages/tokens-studio-for-figma/src/app/components/TokenTooltip/SingleCompositionValueDisplay.tsx 100 (0) 90.9 (9.09) 100 (0) 100 (0)

The AliasBadge component used `value || ''` which treated 0 as falsy,
causing the tooltip to show an empty string instead of '0'. Changed to
`value ?? ''` to only fall back for null/undefined.

Fixes #3776

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@six7 six7 force-pushed the fix/tooltip-zero-value branch from 1654bb3 to 8189b2c Compare February 26, 2026 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Token Tooltip Fails to Display Resolved Value When Value is "0"

1 participant