]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merge of (#9862) to Vaadin 7. 57/557/1
authorAnna Koskinen <anna@vaadin.com>
Wed, 2 Jan 2013 08:22:26 +0000 (10:22 +0200)
committerAnna Koskinen <anna@vaadin.com>
Wed, 2 Jan 2013 08:36:19 +0000 (10:36 +0200)
Tooltip location fix.

Change-Id: Idfdf3385d793569f028fbeaba0b338810095f143

client/src/com/vaadin/client/VTooltip.java
uitest/src/com/vaadin/tests/components/TooltipsOnScrollingWindow.html [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/TooltipsOnScrollingWindow.java [new file with mode: 0644]

index a4c4766e4fa3ee57632948f3fc6ef42e82e6ca49..2fb7c39d5f12a7f05d71d67851678425ae68c7f5 100644 (file)
@@ -117,12 +117,14 @@ public class VTooltip extends VOverlay {
 
                     if (x + offsetWidth + MARGIN - Window.getScrollLeft() > Window
                             .getClientWidth()) {
-                        x = Window.getClientWidth() - offsetWidth - MARGIN;
+                        x = Window.getClientWidth() - offsetWidth - MARGIN
+                                + Window.getScrollLeft();
                     }
 
                     if (y + offsetHeight + MARGIN - Window.getScrollTop() > Window
                             .getClientHeight()) {
-                        y = tooltipEventMouseY - 5 - offsetHeight;
+                        y = tooltipEventMouseY - 5 - offsetHeight
+                                + Window.getScrollTop();
                         if (y - Window.getScrollTop() < 0) {
                             // tooltip does not fit on top of the mouse either,
                             // put it at the top of the screen
diff --git a/uitest/src/com/vaadin/tests/components/TooltipsOnScrollingWindow.html b/uitest/src/com/vaadin/tests/components/TooltipsOnScrollingWindow.html
new file mode 100644 (file)
index 0000000..b251cdf
--- /dev/null
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="http://localhost:8888/" />
+<title>TooltipsOnScrollingWindow</title>
+</head>
+<body>
+       <table cellpadding="1" cellspacing="1" border="1">
+               <thead>
+                       <tr>
+                               <td rowspan="1" colspan="3">TooltipsOnScrollingWindow</td>
+                       </tr>
+               </thead>
+               <tbody>
+                       <tr>
+                               <td>open</td>
+                               <td>/run/com.vaadin.tests.components.TooltipsOnScrollingWindow?restartApplication</td>
+                               <td></td>
+                       </tr>
+                       <tr>
+                               <td>showTooltip</td>
+                               <td>vaadin=runcomvaadintestscomponentsTooltipsOnScrollingWindow::PID_Shoverable-label</td>
+                               <td></td>
+                       </tr>
+                       <tr>
+                               <td>waitForVisible</td>
+                               <td>vaadin=runcomvaadintestscomponentsTooltipsOnScrollingWindow::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td>
+                               <td></td>
+                       </tr>
+                       <tr>
+                               <td>screenCapture</td>
+                               <td></td>
+                               <td>tooltip-is-positioned-correctly</td>
+                       </tr>
+               </tbody>
+       </table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/TooltipsOnScrollingWindow.java b/uitest/src/com/vaadin/tests/components/TooltipsOnScrollingWindow.java
new file mode 100644 (file)
index 0000000..a38f9c2
--- /dev/null
@@ -0,0 +1,55 @@
+package com.vaadin.tests.components;
+
+import com.vaadin.tests.util.TestUtils;
+import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.Label;
+
+public class TooltipsOnScrollingWindow extends TestBase {
+
+    @Override
+    protected void setup() {
+
+        TestUtils
+                .injectCSS(
+                        getMainWindow(),
+                        ".v-generated-body { overflow: auto; } "
+                                + ".v-app, .v-ui { overflow: visible !important;}"
+                                + ".hoverable-label { position: fixed; bottom: 10px; right: 10px;  }"
+                                + ".hidden-label { position: absolute; top: 2000px; left: 2000px;}");
+
+        getLayout().getParent().setHeight("4000px");
+        getLayout().getParent().setWidth("4000px");
+        getLayout().setHeight("4000px");
+        getLayout().setWidth("4000px");
+
+        CssLayout layout = new CssLayout();
+        layout.setHeight("4000px");
+        layout.setWidth("4000px");
+        addComponent(layout);
+
+        Label hoverableLabel = new Label("Hover me");
+        hoverableLabel.setId("hoverable-label");
+        hoverableLabel.setStyleName("hoverable-label");
+        hoverableLabel.setWidth("-1px");
+        hoverableLabel.setDescription("Tooltip");
+        layout.addComponent(hoverableLabel);
+
+        Label hiddenLabel = new Label("Hidden");
+        hiddenLabel.setStyleName("hidden-label");
+        hiddenLabel.setWidth("-1px");
+        layout.addComponent(hiddenLabel);
+
+        getMainWindow().scrollIntoView(hiddenLabel);
+    }
+
+    @Override
+    protected String getDescription() {
+        return "Tooltip is displayed in the wrong place when component is at lower edge of the screen and application with following the css is scrolled vertically.";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 9862;
+    }
+
+}