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

[Bug]: Title attribute for Tag component contains all children #17033

Closed
2 tasks done
clouria opened this issue Jul 24, 2024 · 1 comment
Closed
2 tasks done

[Bug]: Title attribute for Tag component contains all children #17033

clouria opened this issue Jul 24, 2024 · 1 comment
Assignees
Labels

Comments

@clouria
Copy link

clouria commented Jul 24, 2024

Package

@carbon/react

Browser

Chrome, Safari, Firefox, Edge

Package version

v1.62.1

React version

^17.0.0

Description

According to the docs, https://react.carbondesignsystem.com/?path=/docs/components-tag--overview, the Tag component can have a children prop of type node. When given any type other than string as a child, the Tag component acts incorrectly. It adds all of the children to the Title attribute
Screenshot 2024-07-24 at 8 18 22 AM
Screenshot 2024-07-24 at 8 24 32 AM
This was added in this PR 96524a7#diff-bf61738276a5e024a5901f050aa6781f38a21104524c5fcfdf84c9bd8248e8ef

I believe the code is expecting the children to only be a string and in that case this works properly. A fix for this would be to allow a custom title to be passed down as a prop for these scenarios where the title can not be inferred from the child.

Reproduction/example

https://stackblitz.com/edit/github-ynms4h-zd7ufe?file=src%2FApp.jsx

Steps to reproduce

  1. Hover over the Tag and wait for a couple seconds for the Title text to show

Suggested Severity

Severity 3 = User can complete task, and/or has a workaround within the user experience of a given component.

Application/PAL

No response

Code of Conduct

@emyarod
Copy link
Member

emyarod commented Nov 4, 2024

the issue seems to be resolved via

<Text
title={
children !== null &&
children !== undefined &&
typeof children === 'string'
? children
: typeText
}
className={labelClasses}>
so it is recommended that you upgrade your project's version of Carbon to capture this bugfix!

@emyarod emyarod closed this as completed Nov 4, 2024
@github-project-automation github-project-automation bot moved this from 🏗 In Progress to ✅ Done in Design System Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ Done
Development

No branches or pull requests

3 participants