Tooltip location fix. Change-Id: Idfdf3385d793569f028fbeaba0b338810095f143tags/7.0.0.rc1
@@ -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 |
@@ -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> |
@@ -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; | |||
} | |||
} |