Skip to content

Commit

Permalink
Fix closing of modal window curtains while dragging and resizing (#8281)
Browse files Browse the repository at this point in the history
Fixes #7496
  • Loading branch information
ahie authored and tsuoanttila committed Jan 19, 2017
1 parent 066c1ca commit 1adb7ce
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
2 changes: 2 additions & 0 deletions client/src/main/java/com/vaadin/client/ui/VWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,8 @@ public void hide() {

if (vaadinModality) {
hideModalityCurtain();
hideDraggingCurtain();
hideResizingCurtain();
}
super.hide();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package com.vaadin.tests.themes.valo;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

import org.junit.Test;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;

import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.tests.ModalWindow;
import com.vaadin.tests.tb3.SingleBrowserTest;
import org.junit.Test;
import org.openqa.selenium.WebElement;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

public class ModalWindowTest extends SingleBrowserTest {

Expand All @@ -30,7 +35,44 @@ public void modalAnimationsAreDisabled() {
is("none"));
}

@Test
public void modal_curtains_close_correctly() {
openTestURL();

openModalWindow();
new Actions(getDriver())
.moveToElement(findHeaderElement())
.clickAndHold().moveByOffset(1, 1).perform();
assertTrue(isElementPresent(By.className("v-window-draggingCurtain")));
new Actions(getDriver()).sendKeys(findHeaderElement(), Keys.ESCAPE)
.release().perform();
verifyCurtainsNotPresent();

openModalWindow();
new Actions(getDriver())
.moveToElement(findResizingElement())
.clickAndHold().moveByOffset(1, 1).perform();
assertTrue(isElementPresent(By.className("v-window-resizingCurtain")));
new Actions(getDriver()).sendKeys(findResizingElement(), Keys.ESCAPE)
.release().perform();
verifyCurtainsNotPresent();
}

private void openModalWindow() {
$(ButtonElement.class).get(1).click();
}
}

private WebElement findHeaderElement() {
return findElement(By.className("v-window-header"));
}

private WebElement findResizingElement() {
return findElement(By.className("v-window-resizebox"));
}

private void verifyCurtainsNotPresent() {
assertFalse(isElementPresent(By.className("v-window-modalitycurtain")));
assertFalse(isElementPresent(By.className("v-window-draggingCurtain")));
assertFalse(isElementPresent(By.className("v-window-resizingCurtain")));
}
}

0 comments on commit 1adb7ce

Please sign in to comment.