diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-11-18 11:46:23 +0100 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-11-18 13:23:44 +0000 |
commit | 46a0731a5bd6a51d0e7b80c2d596df29bc271710 (patch) | |
tree | b4a26d07e5f98daeee8c89a03b5c8e63a99853b3 /client | |
parent | bc7c4f780fd6f2843cc3910063bfcf6587b99627 (diff) | |
download | vaadin-framework-46a0731a5bd6a51d0e7b80c2d596df29bc271710.tar.gz vaadin-framework-46a0731a5bd6a51d0e7b80c2d596df29bc271710.zip |
Prevent text selection while DnD resizing columns (#16838)
This patch uses a JavaScript workaround to prevent text selection in IE8
and IE9 and Safari.
The selection is prevented everywhere in the DOM while a column is
resizing.
Change-Id: I1e7b9cdc675c83a9666493d8545337d601e40077
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/WidgetUtil.java | 23 | ||||
-rw-r--r-- | client/src/com/vaadin/client/widgets/Grid.java | 9 |
2 files changed, 32 insertions, 0 deletions
diff --git a/client/src/com/vaadin/client/WidgetUtil.java b/client/src/com/vaadin/client/WidgetUtil.java index e9ec163612..b0e0030769 100644 --- a/client/src/com/vaadin/client/WidgetUtil.java +++ b/client/src/com/vaadin/client/WidgetUtil.java @@ -1307,6 +1307,29 @@ public class WidgetUtil { }-*/; /** + * JavaScript hack to prevent text selection in various browsers. + * + * @since + * @param e + * element for enabling or disabling text selection + * @param enable + * <code>true</code> if selection is enabled; </code>false</code> + * if not + */ + public native static void setTextSelectionEnabled(Element e, boolean enable) + /*-{ + if (!enable) { + e.ondrag = function () { return false; }; + e.onselectstart = function () { return false; }; + e.style.webkitUserSelect = "none"; + } else { + e.ondrag = null; + e.onselectstart = null; + e.style.webkitUserSelect = "text"; + } + }-*/; + + /** * The allowed value inaccuracy when comparing two double-typed pixel * values. * <p> diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java index a5a93c19ef..33672517fe 100644 --- a/client/src/com/vaadin/client/widgets/Grid.java +++ b/client/src/com/vaadin/client/widgets/Grid.java @@ -36,6 +36,7 @@ import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.core.shared.GWT; import com.google.gwt.dom.client.BrowserEvents; import com.google.gwt.dom.client.DivElement; +import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.EventTarget; import com.google.gwt.dom.client.NativeEvent; @@ -5580,16 +5581,24 @@ public class Grid<T> extends ResizeComposite implements c)); } } + WidgetUtil.setTextSelectionEnabled(Document + .get().getBody(), false); } @Override public void onComplete() { fireEvent(new ColumnResizeEvent<T>(col)); + + WidgetUtil.setTextSelectionEnabled(Document + .get().getBody(), true); } @Override public void onCancel() { col.setWidth(initialWidth); + + WidgetUtil.setTextSelectionEnabled(Document + .get().getBody(), true); } }); dragger.addTo(td); |