Skip to content

Commit

Permalink
[Tooltip] Support tooltips for disabled buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Oct 15, 2020
1 parent 777c1a1 commit faaba7e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
4 changes: 1 addition & 3 deletions docs/src/pages/components/tooltips/DisabledTooltips.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import Tooltip from '@material-ui/core/Tooltip';
export default function DisabledTooltips() {
return (
<Tooltip title="You don't have permission to do this">
<span>
<Button disabled>A Disabled Button</Button>
</span>
<Button disabled>A Disabled Button</Button>
</Tooltip>
);
}
4 changes: 1 addition & 3 deletions docs/src/pages/components/tooltips/DisabledTooltips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import Tooltip from '@material-ui/core/Tooltip';
export default function DisabledTooltips() {
return (
<Tooltip title="You don't have permission to do this">
<span>
<Button disabled>A Disabled Button</Button>
</span>
<Button disabled>A Disabled Button</Button>
</Tooltip>
);
}
1 change: 0 additions & 1 deletion packages/material-ui/src/ButtonBase/ButtonBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export const styles = {
borderStyle: 'none', // Remove Firefox dotted outline.
},
'&$disabled': {
pointerEvents: 'none', // Disable link interactions
cursor: 'default',
},
'@media print': {
Expand Down
12 changes: 6 additions & 6 deletions packages/material-ui/src/Tooltip/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ const Tooltip = React.forwardRef(function Tooltip(props, ref) {
const handleEnter = (forward = true) => (event) => {
const childrenProps = children.props;

if (event.type === 'mouseover' && childrenProps.onMouseOver && forward) {
childrenProps.onMouseOver(event);
if (event.type === 'pointerenter' && childrenProps.onPointerEnter && forward) {
childrenProps.onPointerEnter(event);
}

if (ignoreNonTouchEvents.current && event.type !== 'touchstart') {
Expand Down Expand Up @@ -501,12 +501,12 @@ const Tooltip = React.forwardRef(function Tooltip(props, ref) {
}

if (!disableHoverListener) {
childrenProps.onMouseOver = handleEnter();
childrenProps.onMouseLeave = handleLeave();
childrenProps.onPointerEnter = handleEnter();
childrenProps.onPointerLeave = handleLeave();

if (!disableInteractive) {
interactiveWrapperListeners.onMouseOver = handleEnter(false);
interactiveWrapperListeners.onMouseLeave = handleLeave(false);
interactiveWrapperListeners.onPointerEnter = handleEnter(false);
interactiveWrapperListeners.onPointerLeave = handleLeave(false);
}
}

Expand Down

0 comments on commit faaba7e

Please sign in to comment.