mui / mui/material-ui

[Tooltip] `The children component of the Tooltip is not forwarding its props correctly` error when focusing another element

Open
#33,476 14 comments 10 reactions 1 assignee View on GitHub

@siriwatknp is already working on this.

Since Aug 22, 2022.

scope: tooltip type: enhancement
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Duplicates
  • I have searched the existing issues
Latest version
  • I have tested the latest version
Current behavior 😯

In the demo in https://mui.com/x/react-data-grid/editing/#validation, we wrap a InputBase into a Tooltip to show the validation error. The problem is that as soon as the user enters the edit mode (double-clicking the cell), we imperatively call inputRef.current.focus() to focus the input and this generates the following error:

The children component of the Tooltip is not forwarding its props correctly.

The problem seems to come from https://github.com/mui/material-ui/blob/6e69c8e8db54305f7602e11ea76b9b13adcf04cd/packages/mui-material/src/Tooltip/Tooltip.js#L425-L429

childNode initially has the correct element —the immediate child of Tooltip—, but when .focus is called, childNode becomes the input, which falls in

https://github.com/mui/material-ui/blob/6e69c8e8db54305f7602e11ea76b9b13adcf04cd/packages/mui-material/src/Tooltip/Tooltip.js#L549-L555

Expected behavior 🤔

No error in the console.

Steps to reproduce 🕹

Steps:

  1. Open https://codesandbox.io/s/magical-brahmagupta-xgisfp?file=/src/App.tsx
  2. Click "Toggle input"
  3. Look at the console
Context 🔦

Related to https://github.com/mui/mui-x/issues/5457

Your environment 🌎
npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.