]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixes button :active state on firefox #12126
authorJohn Ahlroos <john@vaadin.com>
Fri, 26 Jul 2013 08:07:36 +0000 (11:07 +0300)
committerVaadin Code Review <review@vaadin.com>
Fri, 26 Jul 2013 12:53:14 +0000 (12:53 +0000)
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

index e67fa6eceb4b7aee62a7fb99fbea8e4d34d0acfd..840ed39114dd05a85279c58146d1f77236d9c67a 100644 (file)
@@ -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: