diff options
author | Pekka Hyvönen <pekka@vaadin.com> | 2017-05-10 14:42:31 +0300 |
---|---|---|
committer | Ilia Motornyi <elmot@vaadin.com> | 2017-05-10 14:42:31 +0300 |
commit | cbb4393847f02fdbdcd64528918aeacbdc5565e3 (patch) | |
tree | b6003782b956f5f1f9aed2f1d4707d383515a810 /uitest | |
parent | 624a9594b55f0b35e75b9aefd80a97049bc51eed (diff) | |
download | vaadin-framework-cbb4393847f02fdbdcd64528918aeacbdc5565e3.tar.gz vaadin-framework-cbb4393847f02fdbdcd64528918aeacbdc5565e3.zip |
Fix partly missing drag image regression on Safari
Doesn't fix #9261, drag image missing on Safari when dragging grid row because
that has position: absolute and offset.
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/components/grid/GridDragAndDrop.java | 3 | ||||
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/dnd/DragImage.java | 67 |
2 files changed, 69 insertions, 1 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridDragAndDrop.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridDragAndDrop.java index 149dec92e3..529d8cf562 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridDragAndDrop.java +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridDragAndDrop.java @@ -122,7 +122,8 @@ public class GridDragAndDrop extends AbstractTestUIWithLog { // Add drag end listener dragSource.addGridDragEndListener(event -> { - if (event.getDropEffect() == DropEffect.MOVE) { + if (event.getDropEffect() == DropEffect.MOVE + && draggedItems != null) { // If drop is successful, remove dragged item from source Grid ((ListDataProvider<Person>) grid.getDataProvider()).getItems() .removeAll(draggedItems); diff --git a/uitest/src/main/java/com/vaadin/tests/dnd/DragImage.java b/uitest/src/main/java/com/vaadin/tests/dnd/DragImage.java new file mode 100644 index 0000000000..b4ef7ea035 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/dnd/DragImage.java @@ -0,0 +1,67 @@ +package com.vaadin.tests.dnd; + +import java.util.stream.Stream; + +import com.vaadin.annotations.Theme; +import com.vaadin.annotations.Widgetset; +import com.vaadin.event.dnd.DragSourceExtension; +import com.vaadin.server.Page; +import com.vaadin.server.Page.Styles; +import com.vaadin.server.ThemeResource; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.tests.components.uitest.TestSampler; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.VerticalLayout; + +@Theme("valo") +@Widgetset("com.vaadin.DefaultWidgetSet") +public class DragImage extends AbstractTestUIWithLog { + + private final String[] positions = { "default", "relative", "absolute", + "static", "fixed", "sticky", "inherit", "initial", "unset" }; + + @Override + protected void setup(VaadinRequest request) { + HorizontalLayout layout1 = new HorizontalLayout(); + layout1.setCaption("No custom drag image"); + Styles styles = Page.getCurrent().getStyles(); + + Stream.of(positions).forEach(position -> { + Label label = new Label(position); + label.addStyleName(position); + new DragSourceExtension<>(label); + + layout1.addComponents(label, new Label("spacer")); + + styles.add(new StringBuilder(".").append(position) + .append(" { position: ").append(position).append(";}") + .toString()); + }); + + HorizontalLayout layout2 = new HorizontalLayout(); + layout2.setCaption("Custom drag image"); + Stream.of(positions).forEach(position -> { + Label label = new Label(position); + label.addStyleName(position); + new DragSourceExtension<>(label) + .setDragImage(new ThemeResource(TestSampler.ICON_URL)); + layout2.addComponents(label, new Label("spacer")); + + styles.add(new StringBuilder(".").append(position) + .append(" { position: ").append(position).append(";}") + .toString()); + }); + + // #9261 grid row like element that safari can't show the drag image for + String css = ".absolute-pos { position: absolute; top:0; }"; + Label gridRowLikeLabel = new Label(css); + gridRowLikeLabel.addStyleName("absolute-pos"); + new DragSourceExtension(gridRowLikeLabel); + styles.add(css); + + addComponent(new VerticalLayout(layout1, layout2, gridRowLikeLabel)); + } + +} |