-
-
Notifications
You must be signed in to change notification settings - Fork 78.5k
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
Problem with hover tooltips #36253
Comments
The code worked well in v5.1.3. |
Our hover tooltips look fine at https://twbs-bootstrap.netlify.app/docs/5.1/components/tooltips/#enable-tooltips. |
Could you please try my code at codepen.io or jsfiddle.net? Did I made something wrong? Maybe there is a problem with the delay option? |
@mdo Were there any breaking changes to the tooltip functionality since v5.1.3? |
From what I read in the description of this ticket, this feels related to: #35202, isn't it? |
My issue is probably caused by a regression, since it worked fine in v5.1.3. |
@AgentSmith0 Does this CodePen recreate your issue? (equivalent CodePen with 5.1.3) |
@julien-deramond Yes, this recreates my issue. Thank you! |
I think we do not understand the problem well so I will explain the problem in more detail: Here is a video that conveys the point to some extent: output.mp4 |
Not exactly, this is just a side effect. The real problem is that hover tooltips do not hide when going away with the cursor. Just compare the two codepens by julien-deramond. |
@mohammadizanloo55 Try this, it works. ref: #34519 |
Thanks for your explanation, your example worked for me |
Why has this issue been closed? It should be possible to use the title attribute in some way as selector. Otherwise I need to replace all my 1000+ title attributes. There must be some workaround... |
This is also a question of browser compatibility. If a browser does not support JavaScript the title attributes remain as a fallback to the custom tooltips by bootstrap. I think it's important to bring the title attribute back in some way. |
Because you thumb up without any answer 😄
It is being handled by js, and doesn't seem right to keep an empty attribute. More or less it is a fallback way.
//one way
$('body').tooltip({selector: ".tooltip", trigger: "hover", delay: { show: 1000, hide: 0 }});
//other way
$("[title]").each(()=>this.addClass('tooltip-extra-class'))
$('body').tooltip({selector: "[title]", trigger: "hover", delay: { show: 1000, hide: 0 }});
}); Does any of these works for you?
So the code will not work and the title will remain there.
The title attribute was never staying there. If you check the changed code, it was removing the title attribute value |
Unfortunately, none of them would work in my case: I use other libraries, which use the title attribute by default and there are elements with title attributes coming after js initialization of the tooltips, which would not be handled by your code. |
Since title is an optional attribute of buttons, whatever the “other libraries” are doing seems weird if they are based only on the presence/absence of I am interested to provide me, a CodePen with the real use case using these “other libraries”. PS: another workaround is to make an empty title attr during show $('[title]').on('tooltip.bs.show, ev => {
ev.target.attr('title','')
}); |
I think there is a little misunderstanding, the libraries I use do not need the title attribute at runtime, of course. But they use the title attribute to show tooltips. And I would like to have customized tooltips with bootstrap. In the current main branch there is a problem that it isn't possible anymore to make hover tooltips using the code I shared my test case. |
To make things clearer:
How would it be possible to initialize the new element created in the test function as a tooltip without calling a function every time calling the test function and without adding a class or using another attribute than title on it.
This line of code did it all in v5.1.3. |
@GeoSot Is this issue better to understand now? |
I tried to create a workaround, which adds another attribute to the element on hover:
Can anyone explain why this solution isn't working? It seems that the tooltip selector does not work anymore with dynamically created DOM elements, although it is mentioned that it should work (https://twbs-bootstrap.netlify.app/docs/5.1/components/tooltips/#options under selector). |
Does anybody have an idea for a workaround? |
I was able to fix my workaround:
I just changed the attribute name, it seems I was a bit confused by the selector parameter... Anyway, this workaround solves my problem. If you have any improvements or ideas regarding my workaround, please tell. I think this issue can now be closed... Thank you! |
Prerequisites
Describe the issue
When you hover over an element, the tooltip shows, but does not hide when going away from the element. I am using the below.
Reduced test cases
I am including the following files:
JS: https://twbs-bootstrap.netlify.app/docs/5.1/dist/js/bootstrap.bundle.min.js and https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js
CSS: https://twbs-bootstrap.netlify.app/docs/5.1/dist/css/bootstrap.min.css
HTML code:
<span title="test">Test</span>
JS code:
What operating system(s) are you seeing the problem on?
Windows, macOS, Android, iOS, Linux
What browser(s) are you seeing the problem on?
Chrome, Safari, Firefox, Microsoft Edge, Opera
What version of Bootstrap are you using?
main branch
The text was updated successfully, but these errors were encountered: