From 938d4123064a99dda6b01fe0595fc83b3f76ab70 Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Fri, 26 Jul 2013 11:07:36 +0300 Subject: [PATCH] Fixes button :active state on firefox #12126 When doing event.preventDefault() firefox will not trigger the :active selector intentionally (see https://bugzilla.mozilla.org/show_bug.cgi?id=771241). Event.preventDefault() was added to prevent text selection in #10917 but it actually is not needed since the button also uses the user-select:none css attribute which effectivly prevents the text selection. Also now applying the previously browser specific (ie,opera) .v-pressed classname to all browsers to make styling of the pressed state a bit easier to do for all browsers and not reliant on the :active pseudo-class which is a non-standard pseudo-class. Change-Id: Ic67c0abb9d0bf8f47b817609f2928aa8fff3e82b --- client/src/com/vaadin/client/ui/VButton.java | 24 +++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/client/src/com/vaadin/client/ui/VButton.java b/client/src/com/vaadin/client/ui/VButton.java index e67fa6eceb..840ed39114 100644 --- a/client/src/com/vaadin/client/ui/VButton.java +++ b/client/src/com/vaadin/client/ui/VButton.java @@ -142,7 +142,7 @@ public class VButton extends FocusWidget implements ClickHandler { * * -for IE/Opera added CLASSNAME_PRESSED * - * -event.preventDefault() commented from ONMOUSEDOWN (Firefox won't apply + * -event.preventDefault() removed from ONMOUSEDOWN (Firefox won't apply * :active styles if it is present) * * -Tooltip event handling added @@ -189,10 +189,14 @@ public class VButton extends FocusWidget implements ClickHandler { setFocus(true); DOM.setCapture(getElement()); isCapturing = true; - // Prevent dragging (on some browsers); - event.preventDefault(); - if (BrowserInfo.get().isIE() || BrowserInfo.get().isOpera()) { - addStyleName(CLASSNAME_PRESSED); + addStyleName(CLASSNAME_PRESSED); + + if (BrowserInfo.get().isIE8() || BrowserInfo.get().isIE9()) { + /* + * We need to prevent the default behavior on these browsers + * since user-select is not available. + */ + event.preventDefault(); } } break; @@ -204,9 +208,9 @@ public class VButton extends FocusWidget implements ClickHandler { // Click ok disallowNextClick = false; } - if (BrowserInfo.get().isIE() || BrowserInfo.get().isOpera()) { - removeStyleName(CLASSNAME_PRESSED); - } + + removeStyleName(CLASSNAME_PRESSED); + // Explicitly prevent IE 8 from propagating mouseup events // upward (fixes #6753) if (BrowserInfo.get().isIE8()) { @@ -235,9 +239,7 @@ public class VButton extends FocusWidget implements ClickHandler { if (isCapturing) { } setHovering(false); - if (BrowserInfo.get().isIE() || BrowserInfo.get().isOpera()) { - removeStyleName(CLASSNAME_PRESSED); - } + removeStyleName(CLASSNAME_PRESSED); } break; case Event.ONBLUR: -- 2.39.5