question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot put Tooltip on OverflowMenu custom trigger icon

See original GitHub issue

What package(s) are you using?

  • carbon-components
  • [x ] carbon-components-react

Detailed description

Describe in detail the issue you’re having.

I cannot put a Tooltip on an OverflowMenu icon.

Is this issue related to a specific component?

OverflowMenu and TooltipIcon

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

I expected this to happen without errors: Screen Shot 2020-11-12 at 1 51 56 AM

Instead, I got this error in the console:

Warning: validateDOMNesting(...): <button> cannot appear as a descendant of <button>.

I would love to have the ability to put a Tooltip on an OverflowMenu button.

What browser are you working in?

Chrome

My Code

<OverflowMenu
    style={{height: '3rem', maxHeight: '3rem', width: '3rem', background: '#f4f4f4'}}
    renderIcon={() => <TooltipIcon direction={"top"} align={"center"} style={{borderBottom: '0'}} tooltipText={"Status"}> <EventSchedule20 /> </TooltipIcon>}
>
{menuItems}
</OverflowMenu>

Thank you very much for your time! Hopefully there’s a workaround or a solution I’m missing.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
bitfedecommented, Nov 21, 2020

Thank you very much for your feedback @emyarod ! I managed to get it done! Here it is 😃 :

Screen Shot 2020-11-20 at 8 34 36 PM Screen Shot 2020-11-20 at 8 34 49 PM

To achieve this I added the following props:

      <OverflowMenu
        ...
        className="bx--tooltip__trigger bx--tooltip--icon__top leftDropDownBtn"
        ariaLabel={"Category"}
        >
        {menuItems}
      </OverflowMenu>

And this CSS rule applied to these selectors:

.leftDropDownBtn.bx--tooltip--icon__top::after {
    transform: translate(20%, calc(-100% - 12px));
}

(previously the first argument to translate was -50%, that’s why it was going over the endge of the page)

So the reason why it was rendering "Menu" instead of "your tooltip label" was because I was using the prop aria-label instead of ariaLabel in camelcase. As soon as I renamed the prop from aria-label to ariaLabel the correct string showed up.

I’ll close the issue, hopefully anyone that has the same problem can find this helpful.

0reactions
emyarodcommented, Nov 16, 2020

you can add the .bx--tooltip--align-start (or align-end) class to change the alignment. these classes are just taken from the definition and icon tooltip

I’m not entirely sure where the text comes from without seeing your source code but it most likely is the text within .bx--assistive-text if you are following the tooltip/icon-only button markup

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extjs tooltip on overflow button
You can add a tooltip to the overflow button during the afterrender event of the toolbar. The target element would be this.layout.overflowHandler.
Read more >
Tooltips - Bootstrap
The tooltip plugin generates content and markup on demand, and by default places tooltips after their trigger element. Trigger the tooltip via JavaScript:...
Read more >
How to Create an HTML Tooltip [+ Code Templates]
To make a simple tooltip, we'll first create the HTML element that triggers the tooltip when hovered over. We'll create this element as...
Read more >
Tooltip – Carbon Design System
Icon button tooltip anatomy · Icon button: Button that triggers a tooltip on hover or focus · Caret tip: Closely associates container to...
Read more >
Bootstrap tooltips - CoreUI
Elements with the disabled attribute aren't interactive, meaning users cannot focus, hover, or click them to trigger a tooltip (or popover). As a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found