]> source.dussan.org Git - vaadin-framework.git/commitdiff
Revert "DateField popup doesn't close when click on popup button (#14857)"
authorSauli Tähkäpää <sauli@vaadin.com>
Fri, 14 Nov 2014 12:57:15 +0000 (14:57 +0200)
committerVaadin Code Review <review@vaadin.com>
Fri, 14 Nov 2014 15:04:58 +0000 (15:04 +0000)
This reverts commit 457e802e2fe59ec35089a55acdc7b0321a2d4a5a.

Patch does not fix the issue with "slow" clicks when closing the calendar.

Change-Id: I48384e081cf66dd4fc6cded8ecbd94cef5db57bb

client/src/com/vaadin/client/ui/VPopupCalendar.java
uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosing.java [deleted file]
uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosingTest.java [deleted file]

index fbd66cff09a08d391921396c668fe8c98eaacf83..51b2ee22ece774c229f7631ae4b8757789780524 100644 (file)
@@ -27,10 +27,6 @@ import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.event.dom.client.ClickHandler;
 import com.google.gwt.event.dom.client.DomEvent;
 import com.google.gwt.event.dom.client.KeyCodes;
-import com.google.gwt.event.dom.client.MouseOutEvent;
-import com.google.gwt.event.dom.client.MouseOutHandler;
-import com.google.gwt.event.dom.client.MouseOverEvent;
-import com.google.gwt.event.dom.client.MouseOverHandler;
 import com.google.gwt.event.logical.shared.CloseEvent;
 import com.google.gwt.event.logical.shared.CloseHandler;
 import com.google.gwt.i18n.client.DateTimeFormat;
@@ -64,8 +60,7 @@ import com.vaadin.shared.ui.datefield.Resolution;
  * 
  */
 public class VPopupCalendar extends VTextualDate implements Field,
-        ClickHandler, MouseOverHandler, MouseOutHandler,
-        CloseHandler<PopupPanel>, SubPartAware {
+        ClickHandler, CloseHandler<PopupPanel>, SubPartAware {
 
     /** For internal use only. May be removed or replaced in the future. */
     public final Button calendarToggle = new Button();
@@ -80,20 +75,6 @@ public class VPopupCalendar extends VTextualDate implements Field,
     public boolean parsable = true;
 
     private boolean open = false;
-    /*
-     * To resolve #14857. If to click on calendarToggle button when calendar
-     * popup is opened (*1) then we have the following chain of calls:
-     * 
-     * 1) onClose() 2) onClick()
-     * 
-     * In this case we should prevent calling openCalendarPanel() in onClick.
-     */
-    private boolean preventOpenPopupCalendar = false;
-    /*
-     * To resolve #14857. To determine this situation (*1) we use onMouseOver
-     * and OnMouseOut (for calendarToggle button).
-     */
-    private boolean cursorOverCalendarToggleButton = false;
 
     private boolean textFieldEnabled = true;
 
@@ -108,10 +89,6 @@ public class VPopupCalendar extends VTextualDate implements Field,
 
         calendarToggle.setText("");
         calendarToggle.addClickHandler(this);
-
-        calendarToggle.addMouseOverHandler(this);
-        calendarToggle.addMouseOutHandler(this);
-
         // -2 instead of -1 to avoid FocusWidget.onAttach to reset it
         calendarToggle.getElement().setTabIndex(-2);
 
@@ -464,10 +441,7 @@ public class VPopupCalendar extends VTextualDate implements Field,
     @Override
     public void onClick(ClickEvent event) {
         if (event.getSource() == calendarToggle && isEnabled()) {
-            if (!preventOpenPopupCalendar) {
-                openCalendarPanel();
-            }
-            preventOpenPopupCalendar = false;
+            openCalendarPanel();
         }
     }
 
@@ -490,22 +464,15 @@ public class VPopupCalendar extends VTextualDate implements Field,
                 focus();
             }
 
-            open = false;
-
-            if (cursorOverCalendarToggleButton) {
-                preventOpenPopupCalendar = true;
-
-                // To resolve the problem: onMouseOut event not triggered when
-                // moving mouse fast (GWT - all browsers)
-                Timer unPreventClickTimer = new Timer() {
-                    @Override
-                    public void run() {
-                        preventOpenPopupCalendar = false;
-                    }
-                };
-
-                unPreventClickTimer.schedule(300);
-            }
+            // TODO resolve what the "Sigh." is all about and document it here
+            // Sigh.
+            Timer t = new Timer() {
+                @Override
+                public void run() {
+                    open = false;
+                }
+            };
+            t.schedule(100);
         }
     }
 
@@ -675,28 +642,4 @@ public class VPopupCalendar extends VTextualDate implements Field,
         calendar.setRangeEnd(rangeEnd);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * com.google.gwt.event.dom.client.MouseOverHandler#onMouseOver(com.google
-     * .gwt.event.dom.client.MouseOverEvent)
-     */
-    @Override
-    public void onMouseOver(MouseOverEvent event) {
-        cursorOverCalendarToggleButton = true;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * com.google.gwt.event.dom.client.MouseOutHandler#onMouseOut(com.google
-     * .gwt.event.dom.client.MouseOutEvent)
-     */
-    @Override
-    public void onMouseOut(MouseOutEvent event) {
-        cursorOverCalendarToggleButton = false;
-    }
-
 }
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosing.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosing.java
deleted file mode 100644 (file)
index 60508a3..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2000-2014 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.datefield;
-
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractTestUI;
-import com.vaadin.ui.DateField;
-
-public class DateFieldPopupClosing extends AbstractTestUI {
-
-    static final String DATEFIELD_ID = "datefield";
-
-    @Override
-    protected void setup(VaadinRequest request) {
-        final DateField df = new DateField();
-        df.setId(DATEFIELD_ID);
-        addComponent(df);
-    }
-
-    @Override
-    protected String getTestDescription() {
-        return "DateField popup should be closed when click on popup button";
-    }
-
-    @Override
-    protected Integer getTicketNumber() {
-        return 14857;
-    }
-
-}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosingTest.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosingTest.java
deleted file mode 100644 (file)
index ecbd6dd..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.vaadin.tests.components.datefield;
-
-import java.io.IOException;
-
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-
-import com.vaadin.testbench.elements.DateFieldElement;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-public class DateFieldPopupClosingTest extends MultiBrowserTest {
-    /*
-     * try to open/close many times (not one time) because this defect is
-     * reproduced randomly (depends on timer)
-     */
-    private static final int N = 100;
-
-    @Test
-    public void testDateFieldPopupClosing() throws InterruptedException,
-            IOException {
-        openTestURL();
-
-        for (int i = 0; i < N; i++) {
-            clickDateDatePickerButton();
-
-            waitUntil(ExpectedConditions.visibilityOfElementLocated(By
-                    .className("v-datefield-popup")));
-
-            clickDateDatePickerButton();
-
-            waitUntil(ExpectedConditions.invisibilityOfElementLocated(By
-                    .className("v-datefield-popup")));
-        }
-    }
-
-    private void clickDateDatePickerButton() {
-        DateFieldElement dateField = $(DateFieldElement.class).first();
-        dateField.findElement(By.tagName("button")).click();
-    }
-
-}
\ No newline at end of file