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

Prevent tooltip from rendering with empty label #1834

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mazzucchelli
Copy link
Contributor

Why is it needed?

The label prop for the <Tooltip /> component is optional, but it doesn't prevent the tooltip from rendering when it's missing.

Screenshot 2024-12-12 alle 12 13 55

How to test it?

Create a tooltip with an empty label prop

Copy link

changeset-bot bot commented Dec 12, 2024

🦋 Changeset detected

Latest commit: 14b295a

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

This PR includes changesets to release 3 packages
Name Type
@strapi/design-system Patch
@strapi/icons Patch
@strapi/ui-primitives 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

Copy link

vercel bot commented Dec 12, 2024

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

Name Status Preview Comments Updated (UTC)
design-system ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 12, 2024 11:25am

@mazzucchelli mazzucchelli added pr: fix This PR is fixing a bug source: design-system relates to design-system package labels Dec 12, 2024
@HichamELBSI
Copy link
Collaborator

I'm wondering what's the point of using the tooltip to not show the label tooltip ? 🤔

@mazzucchelli
Copy link
Contributor Author

I'm wondering what's the point of using the tooltip to not show the label tooltip ? 🤔

To handle scenarios where the tooltip message is string | undefined. Consumers of the design system are forced to handle this conditional rendering on their side:

export const ButtonWithTooltip = ({
  tooltip,
  tooltipPosition,
  Component = Button,
  ...rest
}) => {
  const button = <Component {...rest} />;

  return tooltip ? (
    <Tooltip label={tooltip} side={tooltipPosition}>
        {button}
    </Tooltip>
  ) : (
    button
  );
};

The same applies to menuitems, links, etc..

If label is optional then we should also handle the case where it can be undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: fix This PR is fixing a bug source: design-system relates to design-system package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants