Material-ui: Tooltip wrapped toggle buttons break highlight

Created on 29 Oct 2019  路  3Comments  路  Source: mui-org/material-ui


For, ToggleButtons wrapped in a tooltip, the toggle highlight doesn't work.

I believe this may be similar to #13206

  • [ x] The issue is present in the latest release.
  • [x ] I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 馃槸


Tooltips break toggle buttons highlighting behavior.

Expected Behavior 馃

I expect Tooltips to not affect highlighting behavior.

Steps to Reproduce 馃暪

https://codesandbox.io/s/lingering-bird-6zrc4?fontsize=14

Context 馃敠

I wanted to put a tooltip on the buttons so users know what the buttons do.

Your Environment 馃寧

| Tech | Version |
| ----------- | ------- |
| Material-UI | v4.5.2 |
| React | 16.11.0 |
| Browser | firefox 69 |
| TypeScript | n/a |

Tooltip question

All 3 comments

We have covered this problem a couple of times already. They are 3 possible approaches, 2 you can leverage today.

  1. Forward the prop to the write element (use a "prop catcher")
  2. Apply the tooltip to the label:
      <ToggleButtonGroup
        value={mode}
        exclusive
        onChange={(e, newValue) => setMode(newValue)}
      >
        <ToggleButton value="kill">
          <Tooltip title="Set mode to kill">
            <span>Kill</span>
          </Tooltip>
        </ToggleButton>
  1. For Material-UI to avoid the cloneElement API: #12921.

@joziahg Yes, I think that the issue you have linked is related, please upvote #12921 if you would like the radio group's solution generalized.

  1. Forward the prop to the write element (use a "prop catcher")

Could you give me a link with some code doing this? I would like to adapt this into our codebase.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mattmiddlesworth picture mattmiddlesworth  路  3Comments

ghost picture ghost  路  3Comments

ryanflorence picture ryanflorence  路  3Comments

anthony-dandrea picture anthony-dandrea  路  3Comments

chris-hinds picture chris-hinds  路  3Comments