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

fix: Tooltip: render non-string content outside of the Text component #557

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

evanfrawley
Copy link

@evanfrawley evanfrawley commented Aug 5, 2024

Description

When using the <Tooltip> component and passing in a non-string React.ReactNode into content, React produces warnings noting that specific elements cannot appear as descendants of a p tag. This change introduces a prop on Tooltip that allows the dev to define what <Text as="_"> property they want to pass, enabling non-string content to be an allowed child in the tooltip and not produce a console warning.

The change introduces a textAs prop which pulls from the textPropTypes['as'] value and passes that down to the <Text> in the tooltip, falling back to the currently hardcoded p value

Here are the warnings that are produced without this change:

CleanShot 2024-08-05 at 10 44 31@2x

CleanShot 2024-08-05 at 10 44 47@2x

Testing steps

Manual testing on the playground page with a non-string ReactNode example

Relates issues / PRs

Copy link

vercel bot commented Aug 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
themes-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 13, 2024 6:51pm
@evanfrawley
Copy link
Author

evanfrawley commented Aug 5, 2024

I'm not quite sure if this is the correct solution -- I think another viable solution would be to have another prop, something like contentAs where that can be one of span div label p as found in text.tsx where that would be passed in something like <Text as={contentAs ?? 'p'}>

@evanfrawley evanfrawley changed the title fix: render non-string content outside of the Text component Aug 5, 2024
@evanfrawley evanfrawley marked this pull request as ready for review August 5, 2024 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant