diff options
author | Artur Signell <artur@vaadin.com> | 2013-06-05 11:06:17 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-06-05 08:55:12 +0000 |
commit | 3c8a3bfcab674e791dc8e91ec5038b7e7e5257d0 (patch) | |
tree | 8a79b5cc0a0d9179f354350219cb8a9e0b5fe9f0 | |
parent | 1b85e5926a0375d87ac076391bfe9d5d0c034da9 (diff) | |
download | vaadin-framework-3c8a3bfcab674e791dc8e91ec5038b7e7e5257d0.tar.gz vaadin-framework-3c8a3bfcab674e791dc8e91ec5038b7e7e5257d0.zip |
Merge of properly focus clicked input element in Webkit (#11854, #11297)
Change-Id: I4c313b55966bcbcd31a40bdd0bf561e887822e51
4 files changed, 61 insertions, 10 deletions
diff --git a/client/src/com/vaadin/client/ui/VCheckBox.java b/client/src/com/vaadin/client/ui/VCheckBox.java index ca1e3ebcdb..166e9acbb4 100644 --- a/client/src/com/vaadin/client/ui/VCheckBox.java +++ b/client/src/com/vaadin/client/ui/VCheckBox.java @@ -16,10 +16,13 @@ package com.vaadin.client.ui; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.vaadin.client.ApplicationConnection; +import com.vaadin.client.BrowserInfo; import com.vaadin.client.Util; import com.vaadin.client.VTooltip; @@ -52,6 +55,17 @@ public class VCheckBox extends com.google.gwt.user.client.ui.CheckBox implements (DOM.getEventsSunk(el) | VTooltip.TOOLTIP_EVENTS)); el = DOM.getNextSibling(el); } + + if (BrowserInfo.get().isWebkit()) { + // Webkit does not focus non-text input elements on click + // (#11854) + addClickHandler(new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + setFocus(true); + } + }); + } } @Override diff --git a/client/src/com/vaadin/client/ui/VNativeButton.java b/client/src/com/vaadin/client/ui/VNativeButton.java index 6e1c5bae77..67fa6f2ee3 100644 --- a/client/src/com/vaadin/client/ui/VNativeButton.java +++ b/client/src/com/vaadin/client/ui/VNativeButton.java @@ -16,14 +16,9 @@ package com.vaadin.client.ui; -import com.google.gwt.core.client.Scheduler; -import com.google.gwt.core.client.Scheduler.ScheduledCommand; -import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; -import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.event.dom.client.MouseEvent; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.Button; @@ -31,7 +26,6 @@ import com.vaadin.client.ApplicationConnection; import com.vaadin.client.BrowserInfo; import com.vaadin.client.MouseEventDetailsBuilder; import com.vaadin.client.Util; -import com.vaadin.client.VConsole; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.button.ButtonServerRpc; @@ -149,8 +143,10 @@ public class VNativeButton extends Button implements ClickHandler { return; } - if (BrowserInfo.get().isSafari()) { - VNativeButton.this.setFocus(true); + if (BrowserInfo.get().isWebkit()) { + // Webkit does not focus non-text input elements on click + // (#11854) + setFocus(true); } if (disableOnClick) { setEnabled(false); diff --git a/client/src/com/vaadin/client/ui/VOptionGroup.java b/client/src/com/vaadin/client/ui/VOptionGroup.java index 2ba8a9e729..ca1f19303d 100644 --- a/client/src/com/vaadin/client/ui/VOptionGroup.java +++ b/client/src/com/vaadin/client/ui/VOptionGroup.java @@ -40,6 +40,7 @@ import com.google.gwt.user.client.ui.Panel; import com.google.gwt.user.client.ui.RadioButton; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ApplicationConnection; +import com.vaadin.client.BrowserInfo; import com.vaadin.client.UIDL; import com.vaadin.client.Util; import com.vaadin.shared.EventId; @@ -153,8 +154,16 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, public void onClick(ClickEvent event) { super.onClick(event); if (event.getSource() instanceof CheckBox) { - final boolean selected = ((CheckBox) event.getSource()).getValue(); - final String key = optionsToKeys.get(event.getSource()); + CheckBox source = (CheckBox) event.getSource(); + + if (BrowserInfo.get().isWebkit()) { + // Webkit does not focus non-text input elements on click + // (#11854) + source.setFocus(true); + } + + final boolean selected = source.getValue(); + final String key = optionsToKeys.get(source); if (!isMultiselect()) { selectedKeys.clear(); } diff --git a/uitest/src/com/vaadin/tests/components/abstractfield/FieldFocusOnClick.java b/uitest/src/com/vaadin/tests/components/abstractfield/FieldFocusOnClick.java new file mode 100644 index 0000000000..30b6a3ad65 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/abstractfield/FieldFocusOnClick.java @@ -0,0 +1,32 @@ +package com.vaadin.tests.components.abstractfield;
+
+import java.util.Arrays;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.NativeButton;
+import com.vaadin.ui.OptionGroup;
+import com.vaadin.ui.TextField;
+
+public class FieldFocusOnClick extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ addComponent(new TextField(null, "TextField"));
+ addComponent(new CheckBox("CheckBox"));
+ addComponent(new OptionGroup(null,
+ Arrays.asList("Option 1", "Option 2")));
+ addComponent(new NativeButton("NativeButton"));
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Webkit doesn't focus non-text input elements when clicked";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 11854;
+ }
+}
\ No newline at end of file |