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

bug: Popover not positioned correct with targetDim.left = 0 #6896

Closed
davidruisinger opened this issue Jun 14, 2016 · 2 comments
Closed

bug: Popover not positioned correct with targetDim.left = 0 #6896

davidruisinger opened this issue Jun 14, 2016 · 2 comments
Assignees
Milestone

Comments

@davidruisinger
Copy link
Contributor

davidruisinger commented Jun 14, 2016

Type: bug

Ionic Version: 2.x

Platform: ios 9 browser

Steps to reproduce:

  1. Create a div that is positioned with left: 0 within the viewport
  2. Add a (click) handler on the div to open a popover
  3. The popover is not positioned according to the div but in the middle of the viewport

I check the source and I think this is because of this line (see: https://github.com/driftyco/ionic/blob/2.0/src/components/popover/popover.ts#L332)

let targetLeft = targetDim && targetDim.left || bodyWidth / 2;

Since targetDim.left = 0 it equals false and will fallback to bodyWidth / 2 which you can also see in the console.logs in the attached screenshot (I clicked on the yellow highlighted div).

popover_misaligned

@davidruisinger davidruisinger changed the title bug: Popover not positioned correct with left: 0 bug: Popover not positioned correct with targetDim.left = 0 Jun 14, 2016
@davidruisinger
Copy link
Contributor Author

Not sure if this is the best solution but for me changing the lines 331 and 332 to this worked:

let targetTop = (targetDim && 'top' in targetDim)  ? targetDim.top : (bodyHeight / 2) - (popoverHeight / 2);
let targetLeft = (targetDim && 'left' in targetDim) ? targetDim.left : bodyWidth / 2;

@brandyscarney
Copy link
Member

Fixed by PR #6900 by @flavordaaave. Thanks!

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants