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

React Admin buttons don't trigger tooltips #10223

Open
michel-paiva opened this issue Sep 19, 2024 · 4 comments
Open

React Admin buttons don't trigger tooltips #10223

michel-paiva opened this issue Sep 19, 2024 · 4 comments

Comments

@michel-paiva
Copy link

What you were expecting:
When I wrap a React Admin custom button with a Tooltip, (for example CreateButton) I expect the Tooltip to be shown when I hover over it.

What happened instead:

The tooltip is not shown when hovering over a custom button wrapped by a Tooltip.

Steps to reproduce:

Related code:

Check the example where in the postListActions I have a CreateButton wrapped by a Tooltip and a material-ui here

Other information:

This wasn't introduced now, it seems like an existing issue.
On material-ui doc they have this section talking about custom child components

Environment

  • React-admin version: 5.2
@fzaninotto
Copy link
Member

Thanks for the report. The problem comes from react-admin's <Button> and its derivatives (like <CreateButton>), which don't use forwardRef.

A PR to fix this is welcome.

@fzaninotto fzaninotto added the bug label Sep 23, 2024
@fzaninotto fzaninotto removed the bug label Oct 3, 2024
@VikashChoudhary001
Copy link

Hi! The bug label was removed recently, so I wanted to confirm if this issue is still open for work or if it has already been resolved.

@fzaninotto
Copy link
Member

The issue is still open, but it's categorized as an enhancement instead of a bug. We'll welcome any PR providing an implementation.

@VikashChoudhary001
Copy link

VikashChoudhary001 commented Nov 13, 2024

Hi @fzaninotto ,

It seems that the issue is caused by the fact that custom buttons like CreateButton do not natively trigger the mouseenter and mouseleave events required by the Tooltip component. To fix this, you can simply wrap the CreateButton inside a div to ensure the tooltip triggers on hover.

Here’s an example of how to fix it:

<Tooltip title="Create Post" >
  <div>
    <CreateButton />
  </div>
</Tooltip>

Let me know if you need further clarification!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants