Browse Source

Use theme font and normal line wrapping for regular tooltips (#9143)

Fixes #9121
tags/8.1.0.alpha8
Leif Åstrand 7 years ago
parent
commit
6cfd4ed55a

+ 1
- 0
all/src/main/templates/release-notes.html View File

@@ -105,6 +105,7 @@
<li>The <tt>HierarchicalDataProvider</tt> interface replaces <tt>Container.Hierarchical</tt> and <<tt>InMemoryHierarchicalDataProvider</tt> replaces <tt>HierarchicalContainer</tt></li>
<li>The <tt>DragSourceExtension</tt> and <tt>DropTargetExtension</tt> extensions replace the old DnD features</li>
<li>OSGi bundle manifests of Vaadin Framework JARs no longer export <tt>/VAADIN</tt>, and there are new mechanisms for publishing static resources for OSGi</li>
<li>Tooltip styles for <tt>ContentMode.PREFORMATTED</tt> have been changed in all built-in themes to use the application font and allow long lines to wrap to multiple lines.</li>
<h2>For incompatible or behaviour-altering changes in 8.0, please see <a href="https://vaadin.com/download/release/8.0/8.0.0/release-notes.html#incompatible">8.0 release notes</a></h2>

+ 1
- 0
client/src/main/java/com/vaadin/client/VTooltip.java View File

@@ -153,6 +153,7 @@ public class VTooltip extends VOverlay {
break;
case PREFORMATTED:
PreElement preElement = Document.get().createPreElement();
preElement.addClassName(CLASSNAME + "-pre");
preElement.setInnerText(info.getTitle());
// clear existing content
description.setHTML("");

+ 5
- 0
compatibility-themes/src/main/themes/VAADIN/themes/base/common/common.scss View File

@@ -129,6 +129,11 @@ body &.v-app .v-app-loading {
cursor: default;
background: #fff;
box-shadow: 0 2px 6px 0 rgba(0, 0, 0, .5);
pre.v-tooltip-pre {
font: inherit;
white-space: pre-wrap;
}
}
.v-tooltip-text {
overflow: auto;

+ 1
- 1
tests/screenshots

@@ -1 +1 @@
Subproject commit a79dd59a14d88413fbfe80071130f3271152aafe
Subproject commit 03a4ef619539700a7bdc9be528cd8e8ad8503253

+ 5
- 0
themes/src/main/themes/VAADIN/themes/valo/shared/_tooltip.scss View File

@@ -119,6 +119,11 @@ $v-tooltip-border-radius: $v-border-radius - 1px !default;
h4 {
color: inherit;
}

pre.v-tooltip-pre {
font: inherit;
white-space: pre-wrap;
}
}
}


+ 2
- 1
uitest/src/main/java/com/vaadin/tests/components/TooltipPosition.java View File

@@ -16,6 +16,7 @@
package com.vaadin.tests.components;

import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.ContentMode;
import com.vaadin.ui.Button;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
@@ -44,7 +45,7 @@ public class TooltipPosition extends AbstractReindeerTestUI {
addComponent(layout);
for (int i = 0; i < NUMBER_OF_BUTTONS; i++) {
Button button = new Button("Button");
button.setDescription(generateTooltipText());
button.setDescription(generateTooltipText(), ContentMode.HTML);
layout.addComponent(button);
}
}

+ 50
- 0
uitest/src/main/java/com/vaadin/tests/components/abstractcomponent/TooltipStyling.java View File

@@ -0,0 +1,50 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.abstractcomponent;

import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.ContentMode;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Label;

public class TooltipStyling extends AbstractTestUI {

@Override
protected void setup(VaadinRequest request) {
Label defaultLabel = new Label(
"I have a tooltip with default settings");
defaultLabel.setDescription(
"This long description should be shown with the application's default font and wrap to several lines as needed."
+ "\n\nThis part should be on a separate line");
defaultLabel.setId("default");
addComponent(defaultLabel);

Label htmlLabel = new Label("I have a tooltip with HTML contents");
htmlLabel.setDescription(
"This is regular text in a tooltip."
+ "<pre>This is a pre tag inside a HTML tooltip. It should use a monospace font and by default not break to multiple lines.</pre>",
ContentMode.HTML);
htmlLabel.setId("html");
addComponent(htmlLabel);
}

@Override
protected String getTestDescription() {
return "Tooltips should be shown with the regular application font and automatically wrap to multiple lines for long contents.<br />"
+ "&lt;pre> tag contents in a HTML tooltip should still behave according to browser defaults.";
}

}

+ 2
- 1
uitest/src/test/java/com/vaadin/tests/components/abstractcomponent/TooltipModesTest.java View File

@@ -36,7 +36,8 @@ public class TooltipModesTest extends TooltipTest {
$(ButtonElement.class).first().showTooltip();

// preformatted is default
checkTooltip("<pre>Several\n lines\n tooltip</pre>");
checkTooltip(
"<pre class=\"v-tooltip-pre\">Several\n lines\n tooltip</pre>");

// Use html inside tooltip
$(ButtonElement.class).get(1).click();

+ 56
- 0
uitest/src/test/java/com/vaadin/tests/components/abstractcomponent/TooltipStylingTest.java View File

@@ -0,0 +1,56 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.abstractcomponent;

import java.io.IOException;
import java.util.Collection;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized.Parameters;

import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.tests.tb3.MultiBrowserThemeTest;
import com.vaadin.tests.tb3.ParameterizedTB3Runner;
import com.vaadin.tests.tb3.SingleBrowserTest;

@RunWith(ParameterizedTB3Runner.class)
public class TooltipStylingTest extends SingleBrowserTest {

private String theme;

public void setTheme(String theme) {
this.theme = theme;
}

@Parameters
public static Collection<String> getThemes() {
return MultiBrowserThemeTest.themesToTest;
}

@Test
public void tooltipStyling() throws IOException {
openTestURL("theme=" + theme);

$(LabelElement.class).id("default").showTooltip();

compareScreen("default");

$(LabelElement.class).id("html").showTooltip();

compareScreen("html");
}
}

+ 6
- 2
uitest/src/test/java/com/vaadin/tests/tb3/MultiBrowserThemeTest.java View File

@@ -17,6 +17,7 @@ package com.vaadin.tests.tb3;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -31,6 +32,10 @@ import org.openqa.selenium.remote.DesiredCapabilities;
@RunWith(ParameterizedTB3Runner.class)
public abstract class MultiBrowserThemeTest extends MultiBrowserTest {

public static final List<String> themesToTest = Collections
.unmodifiableList(Arrays.asList(new String[] { "valo", "reindeer",
"runo", "chameleon", "base" }));

private String theme;

public void setTheme(String theme) {
@@ -39,8 +44,7 @@ public abstract class MultiBrowserThemeTest extends MultiBrowserTest {

@Parameters
public static Collection<String> getThemes() {
return Arrays.asList(new String[] { "valo", "reindeer", "runo",
"chameleon", "base" });
return themesToTest;
}

@Override

Loading…
Cancel
Save