carbon icon indicating copy to clipboard operation
carbon copied to clipboard

[OverflowMenuItem] itemText cannot put Tooltip component

Open dawang021 opened this issue 4 years ago • 11 comments

What package(s) are you using?

"carbon-components": "10.22.0",
"carbon-components-react": "7.22.0",
  • [x] carbon-components
  • [x] carbon-components-react

Detailed description

Describe in detail the issue you're having.

Is this issue related to a specific component?

What did you expect to happen? What happened instead? What would you like to see changed?

What browser are you working in?

What version of the Carbon Design System are you using?

What offering/product do you work on? Any pressing ship or release dates we should be aware of?

Steps to reproduce the issue

  1. Use OverflowMenu, OverflowMenuItem component in DataTable TableCell.
  2. The whole OverflowMenu cannot open anymore.

Sandbox reproduce: https://codesandbox.io/s/overflow-menu-with-tooltip-8iykr?file=/src/index.js

Additional information

  • Screenshots or code
  • Notes

dawang021 avatar Oct 20 '20 05:10 dawang021

@dawang021 it is really helpful if you fill out the issue template so we can help you get sorted out properly. Do you have a link to a reproducible example on CodeSandbox? I am unable to reproduce the problem on our end: https://react.carbondesignsystem.com/?path=/story/datatable--with-overflow-menu

tw15egan avatar Oct 20 '20 18:10 tw15egan

@tw15egan please take a look at this demo in sandbox: https://codesandbox.io/s/overflow-menu-with-tooltip-8iykr?file=/src/index.js

dawang021 avatar Oct 21 '20 07:10 dawang021

I don't believe Tooltip is supported inside of an overflow menu. Overflow menu actions should be short, concise actions that do not need additional information. You could place the tooltip outside of the menu if more information is needed.

Please see this link for more info: https://www.carbondesignsystem.com/components/overflow-menu/usage#formatting

tw15egan avatar Oct 21 '20 17:10 tw15egan

@tw15egan But it works in lower version https://codesandbox.io/s/overflow-menu-with-tooltip-working-well-hsdwo?file=/src/index.js. image

The reason why I want to add Tooltip in OverflowMenuItem is OverflowMenuItem can be disabled, so I want to let users know why this OverflowMenuItem is disabled.

dawang021 avatar Oct 22 '20 06:10 dawang021

OverflowMenu items that are disabled are not in the tab order, so a keyboard user would not be able to navigate to this item and it would cause an a11y violation. That is why this pattern is not recommended.

tw15egan avatar Oct 22 '20 17:10 tw15egan

What is your recommendation/implementation using OverflowMenuItem to notify users why this item is disabled?

I don't think there isn't a need to not let users know the reason for disabled actions.

dawang021 avatar Oct 23 '20 06:10 dawang021

What action are they trying to take that might be disabled? Could any type of UX pattern be used outside of the overflow menu to let the user know why they cannot do something? Does that item even need to be shown if it is not a viable action? Posting user flows here would help our team give guidance around this situation

tw15egan avatar Oct 23 '20 16:10 tw15egan

In IBM cloud VPC load balancer backend pools, we give the reason why this pool is not able to delete. image

dawang021 avatar Nov 11 '20 07:11 dawang021

Can you try setting focusTrap={false} on the Tooltip? Or perhaps try using TooltipDefinition?

tw15egan avatar Nov 11 '20 19:11 tw15egan

I don't think TooltipDefinition would be valid DOM since it would be nesting a button within a button (maybe it would work if you add an href to the OverflowMenuItem since that changes the element to an anchor I believe). seems iffy though

<OverflowMenuItem
  href="#" // renders <a> rather than <button>
  itemText={
    <TooltipDefinition tooltipText="some tooltip text">
      Option 2
    </TooltipDefinition>
  }
/>

your best bet until the Carbon interactive tooltip gets overhauled is probably using requireTitle and title

<OverflowMenuItem
  requireTitle
  itemText="Option 2"
  title="some tooltip text"
/>

edit: looks like custom title is not supported since it defaults to itemText when requireTitle is true (resolved in #7277)

emyarod avatar Nov 11 '20 20:11 emyarod

related https://github.com/carbon-design-system/carbon/issues/6605

emyarod avatar Nov 12 '20 15:11 emyarod

hey @dawang021, thanks for creating the issue. What you're trying to accomplish here with Tooltip and OverflowMenu isn't a supported pattern. This is most likely going to create an accessibility violation.

sstrubberg avatar Nov 28 '22 18:11 sstrubberg