diff --git a/packages/material-ui/src/Tooltip/Tooltip.js b/packages/material-ui/src/Tooltip/Tooltip.js index 7f9848cbba64d4..e119ea3ebb585b 100644 --- a/packages/material-ui/src/Tooltip/Tooltip.js +++ b/packages/material-ui/src/Tooltip/Tooltip.js @@ -367,14 +367,17 @@ const Tooltip = React.forwardRef(function Tooltip(props, ref) { }, leaveDelay); }; - const handleTouchStart = (event) => { + const detectTouchStart = (event) => { ignoreNonTouchEvents.current = true; - const childrenProps = children.props; + const childrenProps = children.props; if (childrenProps.onTouchStart) { childrenProps.onTouchStart(event); } + }; + const handleTouchStart = (event) => { + detectTouchStart(event); clearTimeout(leaveTimer.current); clearTimeout(closeTimer.current); clearTimeout(touchTimer.current); @@ -427,6 +430,7 @@ const Tooltip = React.forwardRef(function Tooltip(props, ref) { ...other, ...children.props, className: clsx(other.className, children.props.className), + onTouchStart: detectTouchStart, ref: handleRef, }; diff --git a/packages/material-ui/src/Tooltip/Tooltip.test.js b/packages/material-ui/src/Tooltip/Tooltip.test.js index f55e60acee219d..3c6b20b061a217 100644 --- a/packages/material-ui/src/Tooltip/Tooltip.test.js +++ b/packages/material-ui/src/Tooltip/Tooltip.test.js @@ -175,6 +175,14 @@ describe('', () => { wrapper.update(); assert.strictEqual(wrapper.find(Popper).props().open, false); }); + + it('should not open if disableTouchListener', () => { + const { container } = render(); + const children = container.querySelector('#testChild'); + fireEvent.touchStart(children); + fireEvent.mouseOver(children); + expect(document.body.querySelectorAll('[role="tooltip"]').length).to.equal(0); + }); }); describe('mount', () => {