Skip to content

Commit

Permalink
Revert "[Tooltip] Fix children mouse over detection (#32321)"
Browse files Browse the repository at this point in the history
This reverts commit dc0e387bcdd6b4654f5e7fb472e6fba18c582deet .

See #32321 (comment) for why.
  • Loading branch information
oliviertassinari committed Jul 20, 2022
1 parent c668efe commit b786ec4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
8 changes: 3 additions & 5 deletions packages/mui-material/src/Tooltip/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,14 +372,10 @@ const Tooltip = React.forwardRef(function Tooltip(inProps, ref) {
return;
}

// Workaround for https://github.com/facebook/react/issues/7769
if (!childNode) {
setChildNode(event.currentTarget);
}
// Remove the title ahead of time.
// We don't want to wait for the next render commit.
// We would risk displaying two tooltips at the same time (native + this one).
else {
if (childNode) {
childNode.removeAttribute('title');
}

Expand Down Expand Up @@ -424,6 +420,8 @@ const Tooltip = React.forwardRef(function Tooltip(inProps, ref) {

const handleFocus = (event) => {
// Workaround for https://github.com/facebook/react/issues/7769
// The autoFocus of React might trigger the event before the componentDidMount.
// We need to account for this eventuality.
if (!childNode) {
setChildNode(event.currentTarget);
}
Expand Down
17 changes: 0 additions & 17 deletions packages/mui-material/src/Tooltip/Tooltip.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,23 +433,6 @@ describe('<Tooltip />', () => {
expect(getByRole('tooltip')).toBeVisible();
expect(handleFocus.callCount).to.equal(1);
});

it('should handle `onMouseOver` forwarding', () => {
const handleMouseOver = spy();
const { getByRole } = render(
<Tooltip enterDelay={100} title="Tooltip">
<button id="testChild" type="submit" onMouseOver={handleMouseOver}>
Hello World
</button>
</Tooltip>,
);

fireEvent.mouseOver(getByRole('button'));
clock.tick(100);

expect(getByRole('tooltip')).toBeVisible();
expect(handleMouseOver.callCount).to.equal(1);
});
});

describe('prop: delay', () => {
Expand Down

0 comments on commit b786ec4

Please sign in to comment.