Hey Rajeev,

Would you review this patch for PopupPanel? It's a cleaned up version
of what we did yesterday. This fixes the odd behavior we noticed where
Popup Panels could not be placed near the right edge of the screen on
IE, and normalizes popups in RTL and LTR modes, so they can't be
dragged off the horizontal edges in either case.

Testing: we made sure popup panels worked as expected in Showcase on
all major browsers, both in Quirks and Standards mode. GWT tests all
still work.

Thanks!

-- 
Alex Rudnick
swe, gwt, atl

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Index: user/src/com/google/gwt/user/client/ui/PopupPanel.java
===================================================================
--- user/src/com/google/gwt/user/client/ui/PopupPanel.java	(revision 3693)
+++ user/src/com/google/gwt/user/client/ui/PopupPanel.java	(working copy)
@@ -575,11 +575,24 @@
   public void setPopupPosition(int left, int top) {
     // Keep the popup within the browser's client area, so that they can't get
     // 'lost' and become impossible to interact with. Note that we don't attempt
-    // to keep popups pegged to the bottom and right edges, as they will then
-    // cause scrollbars to appear, so the user can't lose them.
-    if (left < 0) {
-      left = 0;
+    // to keep popups pegged to the bottom edge; dragging a popup off the bottom
+    // will cause scrollbars to appear, so the user can't lose them.
+
+    int popupWidth = getOffsetWidth();
+    int popupRightEdge = left + popupWidth;
+    int clientLeft = Document.get().getBodyOffsetLeft();
+    int clientWidth = Window.getClientWidth() + clientLeft;
+
+    if (popupRightEdge >= clientWidth) {
+      left = clientWidth - popupWidth;
     }
+
+    // Not always 0. For example, on IE in RTL mode, there's a scrollbar
+    // on the left-hand side.
+    if (left < clientLeft) {
+      left = clientLeft;
+    }
+
     if (top < 0) {
       top = 0;
     }

Reply via email to