diff --git a/packages/mui-material/src/Tooltip/Tooltip.js b/packages/mui-material/src/Tooltip/Tooltip.js index 0d92a708e2a318..86129bd76aebd6 100644 --- a/packages/mui-material/src/Tooltip/Tooltip.js +++ b/packages/mui-material/src/Tooltip/Tooltip.js @@ -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'); } @@ -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); } diff --git a/packages/mui-material/src/Tooltip/Tooltip.test.js b/packages/mui-material/src/Tooltip/Tooltip.test.js index bb61d1d4d066ee..420d32cd7e2c88 100644 --- a/packages/mui-material/src/Tooltip/Tooltip.test.js +++ b/packages/mui-material/src/Tooltip/Tooltip.test.js @@ -433,23 +433,6 @@ describe('', () => { expect(getByRole('tooltip')).toBeVisible(); expect(handleFocus.callCount).to.equal(1); }); - - it('should handle `onMouseOver` forwarding', () => { - const handleMouseOver = spy(); - const { getByRole } = render( - - - , - ); - - fireEvent.mouseOver(getByRole('button')); - clock.tick(100); - - expect(getByRole('tooltip')).toBeVisible(); - expect(handleMouseOver.callCount).to.equal(1); - }); }); describe('prop: delay', () => {