Skip to content

Commit

Permalink
[Tooltip] Fix followCursor preventing onMouseMove on children (mui#23104
Browse files Browse the repository at this point in the history
)
  • Loading branch information
eps1lon authored Oct 16, 2020
1 parent 2caf9b5 commit 97b62fb
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 97b62fb

Please sign in to comment.