tooltip: mouseleave don't trigger on disabled inputs and button
<Tooltip title="mouseleave is not work">
<button disabled>button text</button>
</Tooltip>
https://github.com/react-bootstrap/react-bootstrap/pull/1254
About this issue
- Original URL
- State: open
- Created 9 years ago
- Reactions: 2
- Comments: 27 (6 by maintainers)
Commits related to this issue
- Fix Tooltip won't hide at disabled button close react-component/tooltip#18 — committed to ant-design/ant-design by afc163 7 years ago
- Fix Tooltip won't hide at disabled button close react-component/tooltip#18 — committed to ant-design/ant-design by afc163 7 years ago
- Fix Tooltip won't hide at disabled button close react-component/tooltip#18 — committed to ant-design/ant-design by afc163 7 years ago
Workaround:
{pointer-events: none}style to the disabled button/input.The solution requires both of these steps to work ^
Workaround:
{ pointer-events: none; }style to the disabled button/input.{ cursor: not-allowed; }to the wrapper to fix cursor behavior that stops working with previous step (adding pointer-events: none;).I’ve used @sandwich99’s comment and @jennifer-shehane’s workaround (big thanks!!)
@jennifer-shehane Correct me if I am wrong, but using your solution breaks the non-disabled state, the button stops showing
cursor: pointerwhen active andnot-allowedwhen disabled, I’ve extended the fix so it fully works for both disabled and non-disabled states.Any progress on fixing this?
If any of you guys are using
styled-componentsandtypescriptwithreact, then the following solution/work-around (which depends on the solution(s) from @itsmichaeldiego & @jennifer-shehane mentioned above) can be used:I find a solution, maybe it helps.
<Tooltip title="hhhh"> <Button href="" disabled> 删除 </Button> </Tooltip>Adding an attribute “href”.
According to https://ant.design/components/button-cn/#header
<Button href="http://example.com">Hello world!</Button>则会渲染为<a href="http://example.com"><span>Hello world!</span></a>For those who cannot modify the or add a parent element:
{ pointer-events: none; }style to the disabled button/input.For example:
By disabling
pointer-eventson the button we also lose the desirednot-allowedcursor; for most purposes we can provide a “good enough” fix for this by displaying thenot-allowedcursor only on the children. Note that this means the cursor will not be displayed when the user hovers over the padding on the button. As the pointer-events rule is inherited by default, we must also switch it on for the children. Fortunately, this does not trigger the buttonmouseLeavebug.Yeah, just trial and error. 😄
@afc163 是的 我试了加span也无效