summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/main/java/com/vaadin/client/connectors/grid/GridDragSourceConnector.java14
-rw-r--r--client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java13
-rw-r--r--server/src/main/java/com/vaadin/ui/dnd/event/DropEvent.java25
-rw-r--r--shared/src/main/java/com/vaadin/shared/ui/dnd/DragSourceState.java13
4 files changed, 52 insertions, 13 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
diff --git a/server/src/main/java/com/vaadin/ui/dnd/event/DropEvent.java b/server/src/main/java/com/vaadin/ui/dnd/event/DropEvent.java
index db0e4aa7a9..ed70e8265b 100644
--- a/server/src/main/java/com/vaadin/ui/dnd/event/DropEvent.java
+++ b/server/src/main/java/com/vaadin/ui/dnd/event/DropEvent.java
@@ -78,13 +78,30 @@ public class DropEvent<T extends AbstractComponent> extends Component.Event {
}
/**
- * Get data of type {@code "text"} from the {@code DataTransfer} object.
+ * Get data of any of the types {@code "text"}, {@code "Text"} or {@code
+ * "text/plain"}.
+ * <p>
+ * IE 11 transfers data dropped from the desktop as {@code "Text"} while
+ * most other browsers transfer textual data as {@code "text/plain"}.
*
- * @return Data of type {@code "text"} if exists in the {@code DataTransfer}
- * object, otherwise {@literal null}.
+ * @return First existing data of types in order {@code "text"}, {@code
+ * "Text"} or {@code "text/plain"}, or {@code null} if none of them exist.
*/
public String getDataTransferText() {
- return data.get(DragSourceState.DATA_TYPE_TEXT);
+ // Read data type "text"
+ String text = data.get(DragSourceState.DATA_TYPE_TEXT);
+
+ // IE stores data dragged from the desktop as "Text"
+ if (text == null) {
+ text = data.get(DragSourceState.DATA_TYPE_TEXT_IE);
+ }
+
+ // Browsers may store the key as "text/plain"
+ if (text == null) {
+ text = data.get(DragSourceState.DATA_TYPE_TEXT_PLAIN);
+ }
+
+ return text;
}
/**
diff --git a/shared/src/main/java/com/vaadin/shared/ui/dnd/DragSourceState.java b/shared/src/main/java/com/vaadin/shared/ui/dnd/DragSourceState.java
index 66323a91c6..0fefd05665 100644
--- a/shared/src/main/java/com/vaadin/shared/ui/dnd/DragSourceState.java
+++ b/shared/src/main/java/com/vaadin/shared/ui/dnd/DragSourceState.java
@@ -45,6 +45,19 @@ public class DragSourceState extends SharedState {
*/
public static final String DATA_TYPE_TEXT = "text";
+ /**
+ * Data type {@code "Text"}. IE 11 stores data dragged from the desktop as
+ * "Text" with capital letter.
+ */
+ public static final String DATA_TYPE_TEXT_IE = "Text";
+
+ /**
+ * Data type {@code "text/plain"} for reading data from {@code DataTransfer}
+ * object. Some browsers convert store data with {@code "text"} as {@code
+ * "text/plain"} when transferring data.
+ */
+ public static final String DATA_TYPE_TEXT_PLAIN = "text/plain";
+
public static final String RESOURCE_DRAG_IMAGE = "drag-image";
/**