Skip to content

Commit

Permalink
[Tooltip] Fix followCursor preventing onMouseMove on children
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Oct 16, 2020
1 parent a92256e commit c5b364e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
4 changes: 2 additions & 2 deletions packages/material-ui/src/Tooltip/Tooltip.js
Expand Up @@ -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 };
Expand Down
39 changes: 22 additions & 17 deletions packages/material-ui/src/Tooltip/Tooltip.test.js
Expand Up @@ -598,23 +598,28 @@ describe('<Tooltip />', () => {
});

describe('prop: overrides', () => {
['onTouchStart', 'onTouchEnd', 'onMouseEnter', 'onMouseOver', 'onMouseLeave'].forEach(
(name) => {
it(`should be transparent for the ${name} event`, () => {
const handler = spy();
const { getByRole } = render(
<Tooltip title="Hello World">
<button id="testChild" type="submit" {...{ [name]: handler }}>
Hello World
</button>
</Tooltip>,
);
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(
<Tooltip followCursor title="Hello World">
<button id="testChild" type="submit" {...{ [name]: handler }}>
Hello World
</button>
</Tooltip>,
);
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();
Expand Down

0 comments on commit c5b364e

Please sign in to comment.