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 position wrong on Windows Phone #2861

Closed
vjrantal opened this issue Jan 5, 2015 · 0 comments
Closed

bug: Popover position wrong on Windows Phone #2861

vjrantal opened this issue Jan 5, 2015 · 0 comments

Comments

@vjrantal
Copy link

vjrantal commented Jan 5, 2015

Type: bug

Platform: windows

Popover position calculation doesn't work correctly on IE and the end result is that popovers gets rendered off viewport. See the screenshot below where the issue is highlighted with a red rectangle.

screen shot 2015-01-05 at 11 24 50

The issue is reproducible by opening http://codepen.io/ionic/pen/GpCst (and trying to see the popover). Same issue occurs on both desktop IE 11 and the IE mobile 11 on Windows Phone 8.1. Also, the issue is visible on Cordova-packaged apps run on Windows Phone 8.1.

The root cause seems to be the different value IE returns to $document[0].body.clientWidth when it is called to calculate the correct popover position.

The following diff fixes the issue:

diff --git a/js/angular/service/popover.js b/js/angular/service/popover.js
index 3bfa6eb..d410aac 100644
--- a/js/angular/service/popover.js
+++ b/js/angular/service/popover.js
@@ -93,8 +93,9 @@ function($ionicModal, $ionicPosition, $document, $window) {
     var buttonOffset = $ionicPosition.offset(targetEle);
     var popoverWidth = popoverEle.prop('offsetWidth');
     var popoverHeight = popoverEle.prop('offsetHeight');
-    var bodyWidth = $document[0].body.clientWidth;
-    // clientHeight doesn't work on all platforms for body
+    // Use innerWidth and innerHeight, because clientWidth and clientHeight
+    // doesn't work consistently for body on all platforms
+    var bodyWidth = $window.innerWidth;
     var bodyHeight = $window.innerHeight;

Tested briefly on iOS and Android and seems like the diff doesn't bring regressions to this functionality on those platforms.

@vjrantal vjrantal changed the title Popover position wrong on Windows Phone bug: Popover position wrong on Windows Phone Jan 5, 2015
vjrantal added a commit to vjrantal/ionic that referenced this issue Jan 5, 2015
@perrygovier perrygovier removed the ready label Mar 24, 2015
@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants