Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tooltip] Fix followCursor preventing onMouseMove on children #23104

Merged
merged 1 commit into from Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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