From c8cd986880196cad2d0be08a292d89ec8de8cc03 Mon Sep 17 00:00:00 2001 From: Anna Koskinen Date: Wed, 2 Jan 2013 10:22:26 +0200 Subject: Merge of (#9862) to Vaadin 7. Tooltip location fix. Change-Id: Idfdf3385d793569f028fbeaba0b338810095f143 --- client/src/com/vaadin/client/VTooltip.java | 6 ++- .../components/TooltipsOnScrollingWindow.html | 40 ++++++++++++++++ .../components/TooltipsOnScrollingWindow.java | 55 ++++++++++++++++++++++ 3 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/TooltipsOnScrollingWindow.html create mode 100644 uitest/src/com/vaadin/tests/components/TooltipsOnScrollingWindow.java diff --git a/client/src/com/vaadin/client/VTooltip.java b/client/src/com/vaadin/client/VTooltip.java index a4c4766e4f..2fb7c39d5f 100644 --- a/client/src/com/vaadin/client/VTooltip.java +++ b/client/src/com/vaadin/client/VTooltip.java @@ -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 index 0000000000..b251cdf03b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/TooltipsOnScrollingWindow.html @@ -0,0 +1,40 @@ + + + + + + +TooltipsOnScrollingWindow + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TooltipsOnScrollingWindow
open/run/com.vaadin.tests.components.TooltipsOnScrollingWindow?restartApplication
showTooltipvaadin=runcomvaadintestscomponentsTooltipsOnScrollingWindow::PID_Shoverable-label
waitForVisiblevaadin=runcomvaadintestscomponentsTooltipsOnScrollingWindow::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-is-positioned-correctly
+ + diff --git a/uitest/src/com/vaadin/tests/components/TooltipsOnScrollingWindow.java b/uitest/src/com/vaadin/tests/components/TooltipsOnScrollingWindow.java new file mode 100644 index 0000000000..a38f9c274e --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/TooltipsOnScrollingWindow.java @@ -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; + } + +} -- cgit v1.2.3