-
-
Notifications
You must be signed in to change notification settings - Fork 79k
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
Fix hover-popover/tooltip flickering when mouse re-enters #14273
Conversation
Here's a Bin with your changes: http://jsbin.com/lopupi/1 |
Thank you for creating that, @hnrch02! |
@cvrebert I hate to be a bother, but is there any chance I might get some quick input on this PR? My mind is still pretty fresh, on the topic, so I'd love to get it into acceptable shape if possible. Thank you! |
I'm not really qualified to review this in-depth. You'll have to wait for @fat to get around to reviewing this. |
I was originally triaging this bug in Bootstrap 3.1, and had with this simpler/better fix that now works. I'm going to force-push this much simpler commit in. |
Done. Now it's one-liner with fewer code paths. I don't see any visual glitches that are specific to this change. |
It would be great if you could add either a visual test or unit test for this. |
@@ -103,6 +103,8 @@ | |||
var self = obj instanceof this.constructor ? | |||
obj : $(obj.currentTarget).data('bs.' + this.type) | |||
|
|||
if (self && self.hoverState === 'in') return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be
if (self && self.hoverState == 'in') return
(Filed Medium/phantomjs#209 regarding the unrelated Travis failure.) |
@@ -151,6 +153,8 @@ | |||
|
|||
var $tip = this.tip() | |||
|
|||
if ($tip.is(':visible')) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Semicolon.
Thanks, @cvrebert. Also, I had to add one more commit. It seems like there still needs to be a check for whether or not the tooltip is still visible. I'm wondering if there's a case where this can cause issues when manually triggering the tooltip... If you have a delay AND you quickly hide + show the tooltip. So I think I need to limit my code changes to the enter/leave methods. |
And now I've got what I think is a final PR. I just realized that hoverState IS being set to null, so I can rely on the in/out states == "still/gonna be visible". |
So, why isn't the check |
It probably should be. I'll fix. |
Here's a JS bin with the current set of code changes: I'll work on adding a unit test -- are the visual tests just a manual spot-check? I wasn't sure if my addition would make it too noisy. Thanks again! |
@sgonyea Yeah, the visual tests are completely manual. (Which is why unit tests are preferred when possible.) |
That was fun. The tests helped reveal that I needed to go back to my original commit, and just rely on @cvrebert -- I've added some pretty ugly tests and decided to get some feedback. They involve a lot of teeth pulling, so I'll work on cleaning it up soon. |
Oh right, and a JSBin with the current code: http://jsbin.com/tumar/2 |
test('should not reload the tooltip on subsequent mouseenter events', function () { | ||
var contentData = [] | ||
var titleHtml = function (skipSave) { | ||
var uid = $.fn.bootstrapTooltip.Constructor.prototype.getUID('tooltip').toString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for the toString
here.
everything @hnrch02 said 👍 |
- is(':visible') seems to be the only reliable check, without a refactoring of how hoverState is used - tests need improvement
Done. Thanks a lot for the review, @hnrch02! I've made the assertion inside the tooltip a little less strict. |
@fat So, is this now good to go? |
Fix hover-popover/tooltip flickering when mouse re-enters
yep, thanks! |
Hello everybody. I've found this issue looking for a fix for this joomla issue: joomla/joomla-cms#10821 . If it's not much of a trouble, please help to fix that issue, or just write some advice to joomla developers because they are not trying to fix it, they are just waiting for you. Or maybe you can provide with a hot fix or something... Thanks. |
@creative3d - In Joomla we're still using BS2 which is no longer officially supported. To get the issue fixed, we'll either need to do it ourselves or perhaps it has already been fixed by a 3rd party who decided to keep supporting BS2 |
@C-Lodder, "it has already been fixed" well, it wasn't, as far as I know, I was just able to pay their attention on this from the third attempt two month ago, no movements since then. As for fixing ourselves, I'd like to, but I'm not a developer, have no idea how. Thanks for answering. |
I'll look into it: joomla/joomla-cms#10821 (comment) |
Thanks a lot! |
I'm not exactly happy with the code change I've made to fix this issue, but this at least demonstrates a fix (as well as the bug itself).
JSBin: http://jsbin.com/hajeta/2/
Issues:
Steps to trigger the flickering bug:
Additionally: You can scroll within the popover and see the flicker / (continual) resetting of the inner scrollbar position.
Hopefully the explanation and the demo make sense.
Thank you very much! Bootstrap is fantastic.