aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/com/vaadin/client/ui/VCalendarPanel.java8
-rw-r--r--uitest/src/com/vaadin/tests/components/datefield/PopupClosingWithEsc.java6
-rw-r--r--uitest/src/com/vaadin/tests/components/datefield/PopupClosingWithEscTest.java33
3 files changed, 37 insertions, 10 deletions
diff --git a/client/src/com/vaadin/client/ui/VCalendarPanel.java b/client/src/com/vaadin/client/ui/VCalendarPanel.java
index d1a94ffb9a..c6832226a4 100644
--- a/client/src/com/vaadin/client/ui/VCalendarPanel.java
+++ b/client/src/com/vaadin/client/ui/VCalendarPanel.java
@@ -1094,12 +1094,18 @@ public class VCalendarPanel extends FocusableFlexTable implements
* The keydown/keypress event
*/
private void handleKeyPress(DomEvent<?> event) {
+ // Special handling for events from time ListBoxes.
if (time != null
&& time.getElement().isOrHasChild(
(Node) event.getNativeEvent().getEventTarget().cast())) {
int nativeKeyCode = event.getNativeEvent().getKeyCode();
if (nativeKeyCode == getSelectKey()) {
- onSubmit(); // submit happens if enter key hit down on listboxes
+ onSubmit(); // submit if enter key hit down on listboxes
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ if (nativeKeyCode == getCloseKey()) {
+ onCancel(); // cancel if ESC key hit down on listboxes
event.preventDefault();
event.stopPropagation();
}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/PopupClosingWithEsc.java b/uitest/src/com/vaadin/tests/components/datefield/PopupClosingWithEsc.java
index af43f143c1..f1422b28a3 100644
--- a/uitest/src/com/vaadin/tests/components/datefield/PopupClosingWithEsc.java
+++ b/uitest/src/com/vaadin/tests/components/datefield/PopupClosingWithEsc.java
@@ -25,6 +25,10 @@ public class PopupClosingWithEsc extends AbstractTestUI {
@Override
protected void setup(VaadinRequest request) {
+ DateField df0 = new DateField("Minute");
+ df0.setId("minute");
+ df0.setResolution(Resolution.MINUTE);
+
DateField df1 = new DateField("Day");
df1.setId("day");
df1.setResolution(Resolution.DAY);
@@ -40,7 +44,7 @@ public class PopupClosingWithEsc extends AbstractTestUI {
VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
layout.setSpacing(true);
- layout.addComponents(df1, df2, df3);
+ layout.addComponents(df0, df1, df2, df3);
setContent(layout);
}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/PopupClosingWithEscTest.java b/uitest/src/com/vaadin/tests/components/datefield/PopupClosingWithEscTest.java
index 4c4b894b2b..834517e1bb 100644
--- a/uitest/src/com/vaadin/tests/components/datefield/PopupClosingWithEscTest.java
+++ b/uitest/src/com/vaadin/tests/components/datefield/PopupClosingWithEscTest.java
@@ -22,13 +22,27 @@ import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
-import org.openqa.selenium.interactions.Actions;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class PopupClosingWithEscTest extends MultiBrowserTest {
@Test
+ public void testPopupClosingFromTimeSelect() {
+ openTestURL();
+
+ openPopup("minute");
+ assertTrue(isPopupVisible());
+
+ // Send ESC to the select element to simulate user being
+ // focused on the select while hitting the ESC key.
+ WebElement select = driver.findElement(By
+ .cssSelector(".v-datefield-popup select:first-child"));
+ select.sendKeys(Keys.ESCAPE);
+ assertFalse(isPopupVisible());
+ }
+
+ @Test
public void testPopupClosingDayResolution() {
testPopupClosing("day");
}
@@ -46,22 +60,25 @@ public class PopupClosingWithEscTest extends MultiBrowserTest {
private void testPopupClosing(String dateFieldId) {
openTestURL();
- driver.findElement(
- vaadinLocator("PID_S" + dateFieldId + "#popupButton")).click();
+ openPopup(dateFieldId);
assertTrue(isPopupVisible());
- sendEsc();
+ sendEscToCalendarPanel();
assertFalse(isPopupVisible());
}
+ private void openPopup(String dateFieldId) {
+ driver.findElement(
+ vaadinLocator("PID_S" + dateFieldId + "#popupButton")).click();
+ }
+
private boolean isPopupVisible() {
return !(driver.findElements(By.cssSelector(".v-datefield-popup"))
.isEmpty());
}
- private void sendEsc() {
- WebElement elem = driver.findElement(By
- .cssSelector(".v-datefield-calendarpanel"));
- new Actions(driver).sendKeys(elem, Keys.ESCAPE).perform();
+ private void sendEscToCalendarPanel() {
+ driver.findElement(By.cssSelector(".v-datefield-calendarpanel"))
+ .sendKeys(Keys.ESCAPE);
}
}