Material-ui: [Speed Dial] Passing disabled prop to SpeedDialAction displays a warning in console

Created on 5 Apr 2019  路  3Comments  路  Source: mui-org/material-ui

If you pass { disabled: true } to SpeedDialAction ButtonProps you get a message on the console saying:

Warning: Material-UI: you are providing a disabled `button` child to the Tooltip component.
A disabled element does not fire events.
Tooltip needs to listen to the child element's events to display the title.

Place a `div` container on top of the element.

Expected behaviour: No warning.

SpeedDial

Most helpful comment

@tasinet @JCQuintas I think that this warning should not be logged at all. I don't want to add extra complexity to avoid this error. I just want tooltip to work when button is not disabled and otherwise just don't display tooltip. Simple as that. It's expected behavior. Tooltip should just not register any events on the child when it's disabled.

All 3 comments

The warning should be disabled when tooltipOpen=true, as the disabled button's events are not needed

@tasinet @JCQuintas I think that this warning should not be logged at all. I don't want to add extra complexity to avoid this error. I just want tooltip to work when button is not disabled and otherwise just don't display tooltip. Simple as that. It's expected behavior. Tooltip should just not register any events on the child when it's disabled.

I've got the same problem using Tooltip component.
As a workaround you can set title of the tooltip as empty if your element is disabled.

<Tooltip title={changed ? 'Apply changes' : ''} placement="bottom">
  <Button disabled={!changed} variant="outlined" color="primary" onClick={() => myHandler()}>
    My Button
  </Button>
</Tooltip>

I think that even for disabled element we should show a tooltip. For example in my PHPStorm, I see tooltips for disabled buttons and it's convenient.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aranw picture aranw  路  95Comments

cfilipov picture cfilipov  路  55Comments

sjstebbins picture sjstebbins  路  71Comments

NonameSLdev picture NonameSLdev  路  56Comments

amcasey picture amcasey  路  70Comments