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]: DismissibleTag title prop is confusing and not really what being expected #16959

Closed
2 tasks done
flannanl opened this issue Jul 15, 2024 · 4 comments · Fixed by #17345
Closed
2 tasks done

[Bug]: DismissibleTag title prop is confusing and not really what being expected #16959

flannanl opened this issue Jul 15, 2024 · 4 comments · Fixed by #17345
Assignees
Labels

Comments

@flannanl
Copy link

Package

@carbon/react

Browser

No response

Package version

1.61.0

React version

No response

Description

The title prop in DismissibleTag is currently being mapped to the title prop of the "Clear" button. However, I would expect it to be mapped to the title of the text showing in the tag.

As part of the effort of Carbon 11 migration, we are trying to move the Tag component with the filter and onClose properties to DismissibleTag. We need to show a different title text than the display text we showed in the tag. But because the title prop in DismissibleTag is currently mapped to the title prop for the button, we cannot migrate to use DismissibleTag.

Here is how we use Tag today.

        <Tag
          filter
          onClose={() => onClear()}
        >
          <span className={c('env-value-empty')} title={title}>
            <div className="icon-div">
              {<Link />}
            </div>
            <div className="cpc--ref-resolver-tag__label_container">
              {value}
            </div>
          </span>
        </Tag>

Reproduction/example

See description

Steps to reproduce

See description

Suggested Severity

Severity 2 = User cannot complete task, and/or no workaround within the user experience of a given component.

Application/PAL

IBM Cloud Projects

Code of Conduct

@guidari
Copy link
Contributor

guidari commented Jul 25, 2024

Hey @flannanl
I'm not sure if I understood the issue. Correct me if I'm going off topic regarding your issue.

But if you want to pass the title you can change the default text from "Dismiss" to something else. The only time you cannot change the title it is when the ellipses is active in the tag, then Carbon will enforce a title like "Dismiss {text}" to make sure it is accessible for users to see what is written inside the tag.

The other difference between the old filter tag is that you cannot pass a ReactNode as text, it should pass a string. That way we can make sure it is accessible.

We are planning to move this to stable soon, as for now still experimental. So thanks for your feedback.

@flannanl
Copy link
Author

flannanl commented Jul 25, 2024

@guidari I probably can live with the text not being a ReactNode anymore. However, the title prop today is for the close button, not the text. We have use case where we want the text showing in the tag to be different from the title showing for the text. Looking at the code, the title of the text is always coming from the text while the title prop is directly for the close button.

        <Text title={text} className={`${prefix}--tag__label`}>
          {text}
        </Text>
          <button
            type="button"
            className={`${prefix}--tag__close-icon`}
            onClick={handleClose}
            disabled={disabled}
            aria-label={title}
            title={title}>
            <Close />
          </button>

This is an example how we are using Tag today.

image

@guidari
Copy link
Contributor

guidari commented Aug 2, 2024

I guess what you mean then is that the second tag in this StackBlitz example should also show the title instead of the text if the title is present?

Can you share a Stackblitz of your use case? Because from what I understood you can do it what you have in the screen shot with DismissibleTag

Screenshot 2024-08-02 at 08 46 11
Screenshot 2024-08-02 at 08 46 24

@flannanl
Copy link
Author

flannanl commented Aug 2, 2024

@guidari Your title prop can only decorate the close button on the tag. What I want is to have a title to embellish the text in the tag. That is when I keep my mouse over the tag text, "project-api-key", the title will appear. Today, your title will only appear if my mouse is over the close button or have the close button in focus. This is not acceptable because the context being embellish is not right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

3 participants