-
Notifications
You must be signed in to change notification settings - Fork 6.7k
bug(popover): overflowing window borders #375
Comments
Yeah, there's currently no functionality to intelligently position the popover; this functionality is left to the user. That said, I don't object to adding said functionality, but I'm not sure how best to make it work. Would we have an "order of precedence" to determine in which order to try these? Say, clockwise starting with "top"? And would this positioning be affected only when "auto" was specified or should we account for borders in all the positions, with the option to disable? |
How about being able to list a few options in an order preference? If there is no way to show it properly (fitted on the page) than just use last provided option. |
Visual example: http://craigsworks.com/projects/qtip2/demos/#mouse |
I think it's much more often the case that when a user specifies placement="left" (or "right", "bottom", "top"), she also wants the "auto" behavior in cases where her tooltip/popover doesn't fit on the screen. It's hard to think of a use case when you'd prefer a tooltip to appear off-screen. So rather than adding an "auto" option equivalent to "top,left,bottom,right", I think we should just by default apply smart repositioning after applying the user's chosen placement. That way, in cases where the tooltip would fit with the user's original placement choice, that choice continues to be honored, and in cases where it won't, users' existing code written against earlier versions of angular-bootstrap will automatically benefit from the new intelligent behavior, without having to change any of their code. And users writing against the new angular-bootstrap won't be forced into the "top,left,bottom,right" behavior for all tooltips just to get smart behavior, when they'd prefer to continue to have "top" not be the first placement tried. Helpful to look at prior art which has had the benefit of learning from widespread use. Check out qTip2's "adjust.method" option. By default the behavior is "flip", so this is along the lines of the logic above. qTip2 offers a lot more configuration options than I think we want to bother with, but it does have sensible defaults that I think we could copy. Looking at Twitter Bootstrap, it still has not solved this problem, but several issues have been opened about it, and at least two currently-open PRs (twbs/bootstrap#6848 and twbs/bootstrap#7996) are taking this approach. In the meantime, should we add the auto-flip behavior to angular-bootstrap, which I think would be a clear improvement over current behavior? If Twitter Bootstrap ends up doing the same thing, we'll have gotten there first. Otherwise, we can reevaluate if and when they come up with their solution. |
:1 for this, this just looks terrible when your tooltip is off the page edge |
+1 |
Bootstrap v3 options seems to me quite right:
|
@chrisirhc I do think this is important to be implemented before 1.0.0 release. |
Yes, we should add support for 'auto', it shouldn't be too difficult |
Any news on this? |
+1 |
+1 I also need this feature. Would be very nice to have it. |
+1, this feature would be nice |
+1 from me too. |
+1 |
I'd also love to see this implemented. Thanks for the great job so far! |
👍 ! |
+1 |
8 similar comments
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
👍 |
+1 |
+1 |
Still need this! Were I JS ninja sufficient I would whip it up. Alas :( |
A workaround is to add another directive to the element and bind a mouseenter event or whatever is being used to fire the tooltip and adjust the position: angular.module('app')
.directive('positionTooltip', ['$timeout', function ($timeout) {
return {
restrict: 'A',
scope: false,
link: function (scope, element, attrs) {
var el,
arrow,
offset;
element.bind('mouseenter', function () {
$timeout(function () {
el = element.next();
if (el[0].offsetLeft < 0) {
offset = el[0].offsetLeft;
el.css('left', 0);
arrow = el[0].querySelector('.tooltip-arrow');
arrow = angular.element(arrow);
arrow.css('margin-left', (offset + -5) + 'px');
}
})
});
}
}
}]); |
Does twbs/bootstrap#12328 end up in here somehow? |
+1 |
+1 |
I have a couple of ideas I've been working on for this issue I'd like to share. I need to pull them together in a plunk, then will post them shortly. |
@thegreatmichael thanks for mentioning that issue, we can use that as a reference implementation. |
+1 |
+1, In addition to that the placement of popover should be made similar to hover box. In hover box the position of the placement depends on user cursor or place where mouse enter happens and all the contents in the box appear on the right side of the cursor at bottom. If we reach the bottom of the page the content should re-position to top right and vice-versa when we reach top of the page. |
It's already clear that this is a wanted feature. Please stop all the +1 responsesWe'd like to keep this open for on-topic discussion instead of having to receive notifications for all +1 responses. |
Just thought I'd post my work-around if it's of use to anyone. This enables a position to be set just before the popover becomes visible. I had to tweak the CSS to initially hide the popover until positioning was complete as there were times when the popover would show and then jump into the correct position. |
is this solved? |
I was having this issue with the uib-popover-template directive. It took me a while to figure out how to hack this dang thing (I'm new to coding so it may be simple and I'm an idiot [2 $timeouts were required]) This hack is for uibPopoverTemplatePopup but you could just find out what directive ui-angular is using for the tooltip or w/e by looking at the code. if you don't use popover-append-to-body="true" the popover will be inline (the next element after your button). If you allow the popover to insert directly after the button the offset left may not work (because it offsets to the nearest parent with position relative (I should probably check that). Lastly, I only tested the code if you use popover-placement="top". It will probably work if you use popover-placement="bottom" but I didn't test it. It won't work for left or right (because I'm using margin-left)
Sorry I can't do a better fix. I looked at the source and your using fancy providers, I don't know how to use those things :) |
@gruberjl, we have smart/fixed positioning on our radar. |
Closing in favor of #4762. |
Popovers are overflowing over window borders.
http://plnkr.co/edit/q2Zj1F
Solution might be to add "Auto" positioning option.
The text was updated successfully, but these errors were encountered: