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] Tooltip as a child takes onClick props from parent by default #36087

Open
bendzalaj opened this issue Feb 7, 2023 · 6 comments
Open
Assignees
Labels
component: tooltip This is the name of the generic UI component, not the React module!

Comments

@bendzalaj
Copy link

What's the problem? 🤔

When using MUI Tooltip as a child of an interactive element, it takes onClick props from parent by default. Is this a bug, or intended behaviour? There is a workaround where you can set e.stopPropagation to componentProps, but it would be better if it takes it as default prop.

What are the requirements? ❓

No response

What are our options? 💡

No response

Proposed solution 🟢

No response

Resources and benchmarks 🔗

No response

@bendzalaj bendzalaj added RFC Request For Comments status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Feb 7, 2023
@bendzalaj bendzalaj changed the title [RFC] [RFC] Tooltip reacts to action from parent element Feb 7, 2023
@zannager zannager added the component: tooltip This is the name of the generic UI component, not the React module! label Feb 8, 2023
@samuelsycamore samuelsycamore changed the title [RFC] Tooltip reacts to action from parent element [Tooltip] Tooltip as a child takes onClick props from parent by default Feb 24, 2023
@samuelsycamore samuelsycamore removed the RFC Request For Comments label Feb 24, 2023
@siriwatknp
Copy link
Member

Can you share a CodeSandbox that shows how you use it? Normally, the interactive element should be wrapped with Tooltip, not the other way around?

@siriwatknp siriwatknp added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Feb 27, 2023
@github-actions
Copy link

github-actions bot commented Mar 6, 2023

Since the issue is missing key information and has been inactive for 7 days, it has been automatically closed. If you wish to see the issue reopened, please provide the missing information.

@github-actions github-actions bot closed this as completed Mar 6, 2023
@bendzalaj
Copy link
Author

Hello @siriwatknp , sorry for not responding, this task fell behind. I prepared simple codesandbox example. Try to copy text from tooltip, it changes background color of parent component. Is this usage wrong?
https://codesandbox.io/s/react-mui-forked-mebvog?file=/index.js

@github-actions github-actions bot removed the status: waiting for author Issue with insufficient information label Mar 23, 2023
@github-actions github-actions bot reopened this Mar 23, 2023
@bendzalaj
Copy link
Author

Hi @siriwatknp , anything new on this issue? It is still open. Thanks

@Pichu0357
Copy link

Even I faced the same issue.

<TableCell onClick={handleClick}>
   <Tooltip 
      title='My Awesome Title'
      PopperProps={{
         onClick(e) {
            e.stopPropagation();
         }
      }}
   >
      <span>My Awesome Title</span>
   </Tooltip>
</TableCell>

After attaching a click event handler to PopperProps which tell them to stopPropagation() fixed my issue :)

@amhci
Copy link

amhci commented May 22, 2024

+1.

I just ran into this today; I have a card component that has a descendant tooltip and I noticed that clicking on this tooltip (in order to select its text) was triggering the card's onClick! Easy enough to workaround, just wanted to bump this for visibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: tooltip This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

6 participants