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 does not disappear when button is disabled #9581

Closed
Sokal21 opened this issue Mar 8, 2018 · 21 comments
Closed

Tooltip does not disappear when button is disabled #9581

Sokal21 opened this issue Mar 8, 2018 · 21 comments
Assignees
Labels
❓FAQ issues would be discussed a lot

Comments

@Sokal21
Copy link

Sokal21 commented Mar 8, 2018

Version

3.2.3

Environment

Chrome

Reproduction link

https://codesandbox.io/s/64zprz4vmn

Steps to reproduce

Pass the mouse over the button, and then take it out without passing it over the tooltip

What is expected?

The tooltip should disappear

What is actually happening?

the tooltip stays opened


I'm using styled-components to make styles for my components, I'm creating a custom styled components from an antd Button. The problem is that when this button is disabled and I hover over the button the tooltip does not go away. The issue is related to this specific line: https://github.com/ant-design/ant-design/blob/master/components/tooltip/index.tsx#L121 , here you cant identify that is an antd Button or a coomon button because we are using styled component.

@dengfuping
Copy link
Contributor

dengfuping commented Mar 9, 2018

@Sokal21 You can control whether the tooltip disappears or not with the visible prop, as the demo https://codesandbox.io/s/1r2z9463yl shows.

@ant-design-bot
Copy link
Contributor

Hello @Sokal21. Please provide a online reproduction by forking this link https://u.ant.design/codesandbox-repro. Issues labeled by Need Reproduce will be closed if no activities in 7 days.

@afc163 afc163 added the 🤔 Need Reproduce We cannot reproduce your problem label Mar 9, 2018
@Sokal21
Copy link
Author

Sokal21 commented Mar 9, 2018

@dengfuping I need the tooltip to be displayed even when the button is disabled

@cloudever
Copy link

cloudever commented Mar 9, 2018

Did you notice that everything works well with an inline button?
IMHO that behavior caused by ref exported from the styled-components wrapper and may be related to one.

@Sokal21
Copy link
Author

Sokal21 commented Mar 9, 2018

@cloudever Yes I realized, but I need to use the styled-component wrapper.

@dengfuping dengfuping removed the 🤔 Need Reproduce We cannot reproduce your problem label Mar 13, 2018
@afc163
Copy link
Member

afc163 commented Mar 18, 2018

Try this as workaround: https://codesandbox.io/s/nkwv5l9k40

@afc163 afc163 closed this as completed Mar 18, 2018
@dengfuping
Copy link
Contributor

@afc163 The problem exists still. Maybe we should to make Tooltip more compatible for styled components.

@dengfuping dengfuping reopened this Mar 18, 2018
@afc163
Copy link
Member

afc163 commented Mar 19, 2018

@afc163
Copy link
Member

afc163 commented Mar 19, 2018

const StyledButton = styled(Button)`
  width: 300px;
`;

+ StyledButton.__ANT_BUTTON = true;

@codercatmomi
Copy link

如果是 checkbox呢?
StyledButton.__ANT_BUTTON = true;
这句应该怎么样?

@codercatmomi
Copy link

@afc163
如果是 checkbox呢?
StyledButton.__ANT_BUTTON = true;
这句应该怎么样?

@mcarlotta
Copy link

Experiencing same issue as well in our application. You have to re-hover over it to remove

@dengfuping
Copy link
Contributor

@codercatmomi It's the same as above.

if (((element.type as typeof Button).__ANT_BUTTON || element.type === 'button') &&

@udielenberg
Copy link

@dengfuping

Does adding Button.__ANT_BUTTON = true; has any side effects beside fixing the bug?

@afc163

This comment has been minimized.

@francois-clement-1
Copy link

I fixed this problem with react-component/tooltip#18 (comment).

Workaround:
Wrap the disabled button/input in another element.
Add {pointer-events: none} style to the disabled button/input.

@Podsclan
Copy link

Podsclan commented Mar 27, 2020

I fixed this problem with react-component/tooltip#18 (comment).

Workaround:
Wrap the disabled button/input in another element.
Add {pointer-events: none} style to the disabled button/input.

It worked for me, thank you!

@damiangreen
Copy link
Contributor

This workaround this causes the tooltip to not show at all for me(when the child component is a disabled Switch).

@afc163 afc163 mentioned this issue Apr 6, 2021
1 task
@ofkarakus
Copy link

I fixed this problem with react-component/tooltip#18 (comment).

Workaround:
Wrap the disabled button/input in another element.
Add {pointer-events: none} style to the disabled button/input.

It worked for select[disabled] as well. Thank you!

@anjantalatam
Copy link

Here is a workaround

<Tooltip title={!disabled ? "Tooltip" : null}> 
    <Button
         type="primary"
         disabled={disabled}
     >
         Tooltip Button
     </Button>
</Tooltip>

Open in Codesandbox

@lichspace
Copy link

Here is a workaround

<Tooltip title={!disabled ? "Tooltip" : null}> 
    <Button
         type="primary"
         disabled={disabled}
     >
         Tooltip Button
     </Button>
</Tooltip>

Open in Codesandbox

nice in my case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓FAQ issues would be discussed a lot
Projects
None yet
Development

No branches or pull requests