summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorSergey Budkin <sergey@vaadin.com>2014-09-30 14:58:30 +0300
committerMarkus Koivisto <markus@vaadin.com>2014-10-14 17:57:30 +0300
commitfbca7e57f42bdcbd9db693814d33c3561e3b61dc (patch)
treef83a5ffa5406fd2e4833699f53c5479ac5cedc6a /client
parenta7f63cc427db938df5f92860c152b7763057e822 (diff)
downloadvaadin-framework-fbca7e57f42bdcbd9db693814d33c3561e3b61dc.tar.gz
vaadin-framework-fbca7e57f42bdcbd9db693814d33c3561e3b61dc.zip
Action on click button contained in table is called two times on iOS 8.0 (#14632)
Added suppression of second phantom click event. Change-Id: I97d01831b09f0a41976bbefef389f47a0271fc70
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/ui/VButton.java23
1 files changed, 20 insertions, 3 deletions
diff --git a/client/src/com/vaadin/client/ui/VButton.java b/client/src/com/vaadin/client/ui/VButton.java
index 2e5494ec18..dcc364c1da 100644
--- a/client/src/com/vaadin/client/ui/VButton.java
+++ b/client/src/com/vaadin/client/ui/VButton.java
@@ -95,6 +95,7 @@ public class VButton extends FocusWidget implements ClickHandler {
private HandlerRegistration focusHandlerRegistration;
private HandlerRegistration blurHandlerRegistration;
+ private long lastClickTime = 0;
public VButton() {
super(DOM.createDiv());
@@ -163,13 +164,29 @@ public class VButton extends FocusWidget implements ClickHandler {
int type = DOM.eventGetType(event);
switch (type) {
case Event.ONCLICK:
- // If clicks are currently disallowed, keep it from bubbling or
- // being passed to the superclass.
- if (disallowNextClick) {
+ // fix for #14632 - on mobile safari 8, if we press the button long
+ // enough, we might get two click events, so we are suppressing
+ // second if it is too soon
+ boolean isPhantomClickPossible = BrowserInfo.get().isSafari()
+ && BrowserInfo.get().isTouchDevice()
+ && BrowserInfo.get().getBrowserMajorVersion() == 8;
+ long clickTime = isPhantomClickPossible ? System
+ .currentTimeMillis() : 0;
+ // If clicks are currently disallowed or phantom, keep it from
+ // bubbling or being passed to the superclass.
+ if (disallowNextClick || isPhantomClickPossible
+ && (clickTime - lastClickTime < 100)) { // the maximum
+ // interval observed
+ // for phantom click
+ // is 69, with
+ // majority under
+ // 50, so we select
+ // 100 to be safe
event.stopPropagation();
disallowNextClick = false;
return;
}
+ lastClickTime = clickTime;
break;
case Event.ONMOUSEDOWN:
if (DOM.isOrHasChild(getElement(), DOM.eventGetTarget(event))) {