From 97b62fbcb0b3195f5ca8356a77d656a450404d19 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Fri, 16 Oct 2020 22:29:56 +0200 Subject: [PATCH] [Tooltip] Fix followCursor preventing onMouseMove on children (#23104) --- packages/material-ui/src/Tooltip/Tooltip.js | 4 +- .../material-ui/src/Tooltip/Tooltip.test.js | 39 +++++++++++-------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/packages/material-ui/src/Tooltip/Tooltip.js b/packages/material-ui/src/Tooltip/Tooltip.js index 6e6c50da4a7f43..7cecc57b49fd09 100644 --- a/packages/material-ui/src/Tooltip/Tooltip.js +++ b/packages/material-ui/src/Tooltip/Tooltip.js @@ -446,8 +446,8 @@ const Tooltip = React.forwardRef(function Tooltip(props, ref) { const handleMouseMove = (event) => { const childrenProps = children.props; - if (childrenProps.handleMouseMove) { - childrenProps.handleMouseMove(event); + if (childrenProps.onMouseMove) { + childrenProps.onMouseMove(event); } positionRef.current = { x: event.clientX, y: event.clientY }; diff --git a/packages/material-ui/src/Tooltip/Tooltip.test.js b/packages/material-ui/src/Tooltip/Tooltip.test.js index 9495e8852059b9..44c606100bb06b 100644 --- a/packages/material-ui/src/Tooltip/Tooltip.test.js +++ b/packages/material-ui/src/Tooltip/Tooltip.test.js @@ -598,23 +598,28 @@ describe('', () => { }); describe('prop: overrides', () => { - ['onTouchStart', 'onTouchEnd', 'onMouseEnter', 'onMouseOver', 'onMouseLeave'].forEach( - (name) => { - it(`should be transparent for the ${name} event`, () => { - const handler = spy(); - const { getByRole } = render( - - - , - ); - const type = camelCase(name.slice(2)); - fireEvent[type](getByRole('button')); - expect(handler.callCount).to.equal(1, `${name} should've been called`); - }); - }, - ); + [ + 'onTouchStart', + 'onTouchEnd', + 'onMouseEnter', + 'onMouseMove', + 'onMouseOver', + 'onMouseLeave', + ].forEach((name) => { + it(`should be transparent for the ${name} event`, () => { + const handler = spy(); + const { getByRole } = render( + + + , + ); + const type = camelCase(name.slice(2)); + fireEvent[type](getByRole('button')); + expect(handler.callCount).to.equal(1, `${name} should've been called`); + }); + }); it(`should be transparent for the focus and blur event`, () => { const handleBlur = spy();