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

Tooltips auto placement calculates available space wrongly. #13897

Closed
qris opened this issue Jun 23, 2014 · 7 comments
Closed

Tooltips auto placement calculates available space wrongly. #13897

qris opened this issue Jun 23, 2014 · 7 comments
Labels

Comments

@qris
Copy link

qris commented Jun 23, 2014

If the tooltip is positioned "auto right", then it assumes that its own left + width must be less than the parent width, otherwise it switches to the alternate position:

placement == 'right'  && pos.right + actualWidth      > parentDim.width ? 'left'

However that's not actually true because it ignores the position of the parent (specifically its left offset). Thus it's easy for the tooltip to think there's not enough space when there is.

For example, if you look at the attached screenshot you can see that:

pos.right: 807.75
actualWidth: 191
parentDim.width: 483
parentDim.left: 694.75
parentDim.right: 1177.75

The tooltip should be to the right of the "Add/Remove" button, and clearly there is space: pos.right + actualWidth = 999, while parentDim.right = 1177. However the calculation uses parentDim.width instead of parentDim.right, ignoring the left offset of the parent, so it thinks there isn't enough space.

screenshot from 2014-06-23 12 34 54

qris added a commit to aptivate/cmsbootstrap that referenced this issue Jun 23, 2014
Testing the version from bbcea1d8d5f03eaa480e42bd6812cee22a087893 before
submitting twbs/bootstrap#13897.
@hnrch02
Copy link
Collaborator

hnrch02 commented Jun 23, 2014

Please provide a live example on JS Bin demonstrating the problem.

@qris
Copy link
Author

qris commented Jun 23, 2014

http://jsbin.com/tavewami/1/edit?html,js,output

Note that the "auto" placement moves the tooltip over to the left, unnecessarily. It would fit on the right.

@cvrebert cvrebert added the js label Jun 23, 2014
@cvrebert cvrebert added this to the v3.2.1 milestone Jun 23, 2014
@cvrebert
Copy link
Collaborator

cvrebert commented Jul 3, 2014

Still an issue in v3.2.0: http://jsbin.com/fifosile/4/

@hnrch02
Copy link
Collaborator

hnrch02 commented Jul 4, 2014

@RR2DO2 has fixed this in #12284: http://jsbin.com/tavewami/2

cvrebert added a commit that referenced this issue Jul 7, 2014
rim-odoo pushed a commit to odoo/odoo that referenced this issue Jul 24, 2014
Due to the switch to Bootstrap 3.2 in this version, tooltip auto placement works erroneously (see twbs/bootstrap#13897).
This is a workaround, waiting for a fix in Bootstrap assets.

(Closes #1341)
cvrebert added a commit that referenced this issue Jul 31, 2014
cvrebert added a commit that referenced this issue Aug 6, 2014
cvrebert added a commit that referenced this issue Sep 25, 2014
@hnrch02 hnrch02 modified the milestones: v3.3.1, v3.3.0 Oct 26, 2014
@hnrch02 hnrch02 modified the milestones: v3.3.2, v3.3.1 Nov 11, 2014
@mdo mdo modified the milestones: v3.3.2, v3.3.3 Jan 19, 2015
@natevw
Copy link

natevw commented Mar 5, 2015

I'm guessing this is related to an issue I'm having?

I want the tooltips to show up to the right of my text unless there is not enough space. So according to my understanding of the documentation I should use data-placement="auto right", correct?

But when I use auto right the tooltip almost always shows to the left…even when there is not enough space to the left! If I use auto left, then the tooltip almost always shows to the right…unless there is a whole lot of space to the left. So the opposite setting actually seems to have the desired effect!

Does this bug (and/or #15367) explain the behavior I see, or am I experiencing a different issue?

@hnrch02
Copy link
Collaborator

hnrch02 commented Mar 5, 2015

@natevw Can you test if the changes from #15368 fix your problem?

@cvrebert cvrebert added this to the v3.3.5 milestone Mar 15, 2015
@cvrebert cvrebert removed this from the v3.3.4 milestone Mar 15, 2015
@mdo mdo modified the milestones: v3.3.5, v3.3.6 Jun 16, 2015
@mdo
Copy link
Member

mdo commented Jun 18, 2015

Punting as a won't fix—v4 includes a new positioning library for our affix, tooltips, and popovers.

@mdo mdo closed this as completed Jun 18, 2015
@mdo mdo removed this from the v3.3.6 milestone Jun 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
@mdo @natevw @cvrebert @qris @hnrch02 and others