From 0fd59e941bb8ed0418cbb75a05c507aaeba09e47 Mon Sep 17 00:00:00 2001 From: Anna Koskinen Date: Tue, 28 Nov 2017 13:34:00 +0200 Subject: [PATCH] Fix styling of Window control buttons to show focus (#10285) Fixes #8918 --- tests/screenshots | 2 +- .../themes/valo/components/_window.scss | 29 +++++++++++ .../themes/valo/WindowControlButtonFocus.java | 25 ++++++++++ .../valo/WindowControlButtonFocusTest.java | 48 +++++++++++++++++++ 4 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 uitest/src/main/java/com/vaadin/tests/themes/valo/WindowControlButtonFocus.java create mode 100644 uitest/src/test/java/com/vaadin/tests/themes/valo/WindowControlButtonFocusTest.java diff --git a/tests/screenshots b/tests/screenshots index a20d0108ad..310bb9b24f 160000 --- a/tests/screenshots +++ b/tests/screenshots @@ -1 +1 @@ -Subproject commit a20d0108ad315b1b5a4626619cd157e03cfa7b7f +Subproject commit 310bb9b24f810a041376be5e926c5859cda8efb1 diff --git a/themes/src/main/themes/VAADIN/themes/valo/components/_window.scss b/themes/src/main/themes/VAADIN/themes/valo/components/_window.scss index 52dac4f6f1..75f914a50b 100644 --- a/themes/src/main/themes/VAADIN/themes/valo/components/_window.scss +++ b/themes/src/main/themes/VAADIN/themes/valo/components/_window.scss @@ -188,6 +188,31 @@ $v-window-modality-curtain-background-color: #222 !default; color: inherit; } } + + .#{$primary-stylename}-closebox:focus::after { + content: ""; + position: absolute; + top: round($v-unit-size/6); + right: round($v-unit-size/6); + bottom: round($v-unit-size/6); + left: round($v-unit-size/18); + border-radius: $v-window-border-radius; + + @include valo-focus-style; + } + + .#{$primary-stylename}-maximizebox:focus::after, + .#{$primary-stylename}-restorebox:focus::after { + content: ""; + position: absolute; + top: round($v-unit-size/6); + right: round($v-unit-size/18); + bottom: round($v-unit-size/6); + left: round($v-unit-size/6); + border-radius: $v-window-border-radius; + + @include valo-focus-style; + } .#{$primary-stylename}-closebox { padding-right: round($v-unit-size/9); @@ -222,6 +247,10 @@ $v-window-modality-curtain-background-color: #222 !default; width: $v-unit-size; padding-right: 0; border-bottom-left-radius: $v-window-border-radius; + + &:focus::after { + left: round($v-unit-size/6); + } } } diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/WindowControlButtonFocus.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/WindowControlButtonFocus.java new file mode 100644 index 0000000000..ce30991be1 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/WindowControlButtonFocus.java @@ -0,0 +1,25 @@ +package com.vaadin.tests.themes.valo; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Label; +import com.vaadin.ui.Window; + +public class WindowControlButtonFocus extends AbstractTestUI { + @Override + protected void setup(VaadinRequest request) { + Window window = new Window("Window", new Label()); + window.center(); + addWindow(window); + } + + @Override + protected Integer getTicketNumber() { + return 8918; + } + + @Override + protected String getTestDescription() { + return "Window control buttons should have noticeable focus styles."; + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/themes/valo/WindowControlButtonFocusTest.java b/uitest/src/test/java/com/vaadin/tests/themes/valo/WindowControlButtonFocusTest.java new file mode 100644 index 0000000000..fb095c07b4 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/themes/valo/WindowControlButtonFocusTest.java @@ -0,0 +1,48 @@ +package com.vaadin.tests.themes.valo; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.WindowElement; +import com.vaadin.testbench.parallel.Browser; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class WindowControlButtonFocusTest extends MultiBrowserTest { + + @Override + public List getBrowsersToTest() { + return Arrays.asList(Browser.CHROME.getDesiredCapabilities(), + Browser.IE11.getDesiredCapabilities()); + } + + @Test + public void focusMaximize() throws IOException, InterruptedException { + openTestURL(); + + WebElement window = $(WindowElement.class).first(); + WebElement maximize = window + .findElement(By.className("v-window-maximizebox")); + + executeScript("arguments[0].focus()", maximize); + compareScreen(window, "maximize-focused"); + } + + @Test + public void focusClose() throws IOException { + openTestURL(); + + WebElement window = $(WindowElement.class).first(); + WebElement close = window + .findElement(By.className("v-window-closebox")); + + executeScript("arguments[0].focus()", close); + compareScreen(window, "close-focused"); + } + +} -- 2.39.5