diff options
author | Adam Wagner <wbadam@users.noreply.github.com> | 2017-05-17 16:28:53 +0300 |
---|---|---|
committer | Pekka Hyvönen <pekka@vaadin.com> | 2017-05-17 16:28:53 +0300 |
commit | df360681ae33025f83415bfbc93391932ad13ed9 (patch) | |
tree | ceee93baa1494ea78307f6d21e653b4b48b56d83 /client/src | |
parent | 431debc477bc669a0a6c491e62ee7174ae883fd0 (diff) | |
download | vaadin-framework-df360681ae33025f83415bfbc93391932ad13ed9.tar.gz vaadin-framework-df360681ae33025f83415bfbc93391932ad13ed9.zip |
Fix DnD issues regarding data type text (#9347)
* First dragged data should not contain new line character at the beginning
* Return any of "text", "Text" or "text/plain" in the method of getDataTransferText()
* Set only data of type "text" for IE on dragstart
* Clarify return of getDataTransferText() method
* Ignore generated data that is null
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/main/java/com/vaadin/client/connectors/grid/GridDragSourceConnector.java | 14 | ||||
-rw-r--r-- | client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java | 13 |
2 files changed, 18 insertions, 9 deletions
diff --git a/client/src/main/java/com/vaadin/client/connectors/grid/GridDragSourceConnector.java b/client/src/main/java/com/vaadin/client/connectors/grid/GridDragSourceConnector.java index f1ac15703e..303ffa0b2c 100644 --- a/client/src/main/java/com/vaadin/client/connectors/grid/GridDragSourceConnector.java +++ b/client/src/main/java/com/vaadin/client/connectors/grid/GridDragSourceConnector.java @@ -212,12 +212,14 @@ public class GridDragSourceConnector extends DragSourceExtensionConnector { getDraggedRows(dragStartEvent).forEach(row -> { Map<String, String> rowDragData = getRowDragData(row); rowDragData.forEach((type, data) -> { - if (dataMap.containsKey(type)) { - dataMap.put(type, data); - } else { - // Separate data with new line character when multiple rows - // are dragged - dataMap.put(type, dataMap.get(type) + "\n" + data); + if (!(data == null || data.isEmpty())) { + if (!dataMap.containsKey(type)) { + dataMap.put(type, data); + } else { + // Separate data with new line character when multiple rows + // are dragged + dataMap.put(type, dataMap.get(type) + "\n" + data); + } } }); }); diff --git a/client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java b/client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java index a0f6280ca5..5c91e91714 100644 --- a/client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java +++ b/client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java @@ -194,9 +194,16 @@ public class DragSourceExtensionConnector extends AbstractExtensionConnector { // Always set something as the text data, or DnD won't work in FF ! dataMap.putIfAbsent(DragSourceState.DATA_TYPE_TEXT, ""); - // Set data to the event's data transfer - dataMap.forEach((type, data) -> nativeEvent.getDataTransfer() - .setData(type, data)); + if (!BrowserInfo.get().isIE11()) { + // Set data to the event's data transfer + dataMap.forEach((type, data) -> nativeEvent.getDataTransfer() + .setData(type, data)); + } else { + // IE11 accepts only data with type "text" + nativeEvent.getDataTransfer() + .setData(DragSourceState.DATA_TYPE_TEXT, + dataMap.get(DragSourceState.DATA_TYPE_TEXT)); + } // Initiate firing server side dragstart event when there is a // DragStartListener attached on the server side |