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

fix(popover)(tooltip): "auto" position is not working correctly #2796

Closed
nfiles opened this issue Oct 4, 2017 · 21 comments
Closed

fix(popover)(tooltip): "auto" position is not working correctly #2796

nfiles opened this issue Oct 4, 2017 · 21 comments

Comments

@nfiles
Copy link

nfiles commented Oct 4, 2017

Feature

"auto" positioning in the [popover] directive. This could be related to issue #2661, but I'm not sure.

Bugs

  1. The popover goes off the top of the screen by about 100 pixels before it moves to the "bottom" position.
  2. When the popover would go over the right side of the screen, it always resorts to the "top" position.

Context

version: 1.9.3

The application is a dashboard with draggable tiles, each having a popover in the top right corner.

This is the current configuration for the popover:

  • [popover]="popoverTemplate"
  • placement="auto"
  • container="body" (several parent elements have overflow: hidden)
  • [outsideClick]="true"

I have created a simplified demo here: https://github.com/nfiles/ngx-bootstrap-popover-issue-demo

Misc

I wasn't sure where to go next in my debugging, so I started to look at the source. In src/positioning/ng-positioning.ts at line 197 I noticed that if the "top" and "bottom" else-if blocks were switched, everything worked as expected. I assume this is because "top" is preferred over "bottom", but I do not know why the "top" position is chosen when the popover is going off screen.

@nfiles
Copy link
Author

nfiles commented Oct 4, 2017

I deployed the demo to now.sh (https://ngx-bootstrap-issue-demo-smunotreuo.now.sh/) for examination. Strangely, I was able to recreate both issues locally, but the deployed version behaves a little differently and Bug 1 (going off the top of the screen by ~100 pixels) does not appear to happen anymore.

Update: It seems that the bug depends on window resolution. Bug 1 occurs in the deployed version if the the resolution is 1280x800, but not 1440x900. This was tested using the Chrome Developer Tools.

@valorkin
Copy link
Member

valorkin commented Nov 6, 2017

Thanks for demo! We will be reworking auto positioning from zero, cuz now it's more experimental and works only for static use cases

@nfiles
Copy link
Author

nfiles commented Nov 6, 2017

You're welcome and thank you so much for your response! I think we can just use a small modal in our use case. Good luck with the auto positioning rework.

@valorkin
Copy link
Member

valorkin commented Nov 9, 2017

I will need some luck, positioning is a hell

@cannontechnology
Copy link

Is this issue actively being worked on or has it been tabled?

@valorkin
Copy link
Member

valorkin commented Dec 5, 2017

V2 is stable and we are fixing mostly datepicker and build issue before releasing it
PS you can see issues marked as roadmap aggregation issues per component, this is a plan for v2 to 3
Positioning is a part of it

@YevheniiaMazur YevheniiaMazur changed the title "auto" position goes off screen fix(popover): "auto" position is not working correctly Jan 15, 2018
@YevheniiaMazur YevheniiaMazur changed the title fix(popover): "auto" position is not working correctly fix(popover)(tooltip): "auto" position is not working correctly Jan 16, 2018
@diegofrata
Copy link

Any updates on this? Hitting this issue too.

@aldus25
Copy link

aldus25 commented Mar 1, 2018

Add a parent div element with the class property of 'position-relative' and it will solve your problem

@sankarkolluri
Copy link

@aldus25 Could you please be little more specific - which element should be wrapped inside a parent div (the trigger control or the popover)?

@sivabhusarapu
Copy link

Any ETA on this issue? we are still facing this issue.
If you have any workaround to fix this issue, please let us know. As of now if the button is at corner of the window or any dialog, the popover is being cut. Please suggest. Thanks!

@aldus25
Copy link

aldus25 commented Sep 20, 2018

Add a parent div element with the class property of 'position-relative' and it will solve your problem

@sivabhusarapu
Copy link

@aldus25 can you please give me any demo link kinda. really not sure when you say wrapping over a relatively positioned div. very much appreciated.

@aldus25
Copy link

aldus25 commented Sep 20, 2018

The tooltip auto is absolute positioned, so if it doesnt find a relative positioned parent it will use the window, body or any tag available. You need to wrap the tooltip with any tag but this tag has to have a position: relative css style. For more details on positioning please refer to: https://learn.shayhowe.com/advanced-html-css/detailed-css-positioning/

@pintojeremy
Copy link

Any updates ?
I ran into issues with auto placement too.
Besides those two buggy behaviors listed above, in some cases element wont find any placement and appear on top left corner.

Found out that autoPosition method will not return any default placement if there is enough space in each directions.
You can reproduce by playing with @nfiles demo (https://ngx-bootstrap-issue-demo-smunotreuo.now.sh/), just drag 'Tile 3' to the center. Demo gif.
Returning a default position will fix this issue and its easy, even if a rework should be done.

Would you like a PR ?

As @valorkin said, positioning is a hell of a problem. Bootstrap uses a great 3rd party library, (popper.js), why don't you use it as well in this project ? Is this only to avoid additional dependencies ?

@ChristianGalvez23
Copy link

ChristianGalvez23 commented Oct 11, 2018

Any solution for this? I have several tooltips implemented with this project but whe the element is near of a corner the tooltip get cut a little. It's obviously about positioning.

@dotob
Copy link

dotob commented Oct 18, 2018

like @Waowam i think you should use popper.js

@jvinai
Copy link

jvinai commented Nov 5, 2018

I need to do a left or right display of a popover depending of the room but i cant use placement with 'right left' option so i have to use auto instead.
Using auto display the popover on top on my element and it is cut in half.

Any solution or plan for fixing this bug ?

@odedkeren1
Copy link

We will be happy to have this fix as well !!!
Looking forward

@aburht
Copy link

aburht commented Mar 11, 2019

Any updates on this

@ludmilanesvitiy
Copy link
Contributor

Hello everyone! This issue fixed in version 3.3.0. Positioning service fully rewrote: https://github.com/valor-software/ngx-bootstrap/blob/development/CHANGELOG.md
I've tried this example with 3.3.0 version and this is my results:
Peek 2019-03-19 12-43

@ludmilanesvitiy
Copy link
Contributor

Fixed in #5027

@ghost ghost removed the needs review label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.