* Disable animate-out for VWindow by default Fixes #5891tags/8.5.0.alpha1
@@ -709,7 +709,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, | |||
hideDraggingCurtain(); | |||
hideResizingCurtain(); | |||
} | |||
super.hide(); | |||
super.hide(false, true, false); | |||
int curIndex = getWindowOrder(); | |||
// Remove window from windowOrder to avoid references being left |
@@ -0,0 +1,43 @@ | |||
package com.vaadin.tests; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.TextField; | |||
import com.vaadin.ui.Window; | |||
public class FocusOutsideWindow extends AbstractTestUI { | |||
private boolean focusTextF = true; | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
Button button = new Button("Open window"); | |||
Button focusBut = new Button("Focus TextField/DefaultFocus", e -> { | |||
focusTextF = !focusTextF; | |||
}); | |||
button.setId("buttonOp"); | |||
focusBut.setId("focusBut"); | |||
final TextField textField = new TextField("Focus shoud go here"); | |||
button.addClickListener(new Button.ClickListener() { | |||
public void buttonClick(Button.ClickEvent event) { | |||
Window window = new Window("WINDOW"); | |||
window.setHeight("100px"); | |||
// window.setModal(true); | |||
window.addCloseListener(new Window.CloseListener() { | |||
@Override | |||
public void windowClose(Window.CloseEvent e) { | |||
if (focusTextF) { | |||
textField.focus(); | |||
} | |||
} | |||
}); | |||
addWindow(window); | |||
} | |||
}); | |||
addComponent(button); | |||
addComponent(focusBut); | |||
addComponent(textField); | |||
} | |||
} |
@@ -0,0 +1,31 @@ | |||
package com.vaadin.tests; | |||
import com.vaadin.testbench.elements.TextFieldElement; | |||
import com.vaadin.testbench.elements.WindowElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
import org.junit.Test; | |||
import org.openqa.selenium.By; | |||
import org.openqa.selenium.WebElement; | |||
import static org.junit.Assert.assertEquals; | |||
public class FocusOutsideWindowTest extends MultiBrowserTest { | |||
@Test | |||
public void verifyTextFieldFocused() throws Exception { | |||
openTestURL(); | |||
WebElement openW = findElement(By.id("buttonOp")); | |||
WebElement focusBut = findElement(By.id("focusBut")); | |||
// Closing window should focus TexField | |||
openW.click(); | |||
TextFieldElement textField = $(TextFieldElement.class).first(); | |||
WindowElement window = $(WindowElement.class).first(); | |||
window.close(); | |||
assertEquals(textField.getWrappedElement(), getFocusedElement()); | |||
// Closing window should focus button back(default behaviour) | |||
focusBut.click(); | |||
openW.click(); | |||
$(WindowElement.class).first().close(); | |||
assertEquals(openW, getFocusedElement()); | |||
} | |||
} |