Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow React.ReactNode as Token content #2954

Merged
merged 3 commits into from
Mar 1, 2023
Merged

Conversation

iansan5653
Copy link
Contributor

Updates the props of Token to accept any ReactNode instead of just string in the text prop. This is a non-breaking change because all strings will still work fine.

This required updating the token somewhat because we were previously generating an aria-label like ${text}, press backspace or delete to remove. If text was, say, an object, this label would become [object Object], press backspace or delete to remove. So instead, we now render this as a VisuallyHidden text inside the token so it becomes part of the token's computed content without overriding it. This is more accessible anyway because it doesn't require placing a label on a non-interactive span.

Closes #2952

@iansan5653 iansan5653 requested review from a team and joshblack February 28, 2023 23:08
@changeset-bot
Copy link

changeset-bot bot commented Feb 28, 2023

🦋 Changeset detected

Latest commit: 8167868

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

This PR includes changesets to release 1 package
Name Type
@primer/react 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 28, 2023

size-limit report 📦

Path Size
dist/browser.esm.js 94.49 KB (-0.01% 🔽)
dist/browser.umd.js 95.06 KB (-0.02% 🔽)

@iansan5653 iansan5653 temporarily deployed to github-pages February 28, 2023 23:16 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2954 February 28, 2023 23:17 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2954 February 28, 2023 23:17 Inactive
Copy link
Member

@joshblack joshblack left a comment

Choose a reason for hiding this comment

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

Thanks for doing this! 🙌

@joshblack joshblack added this pull request to the merge queue Mar 1, 2023
Merged via the queue into main with commit 041dd15 Mar 1, 2023
@joshblack joshblack deleted the token-reactnode-content branch March 1, 2023 21:48
@primer-css primer-css mentioned this pull request Mar 1, 2023
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.

Support non-string content in Token
2 participants