summaryrefslogtreecommitdiffstats
path: root/client/src
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2016-01-24 15:30:15 +0200
committerTeemu Suo-Anttila <teemusa@vaadin.com>2016-04-11 09:12:57 +0000
commite4703b14fdfb312b8b6d71e78d1a7f13b5e2a933 (patch)
treef31583e02ee4a9680b3d700e54a961113ffac082 /client/src
parent433dc8025ab7803fc25ef67e29fc67f7bb4d7d71 (diff)
downloadvaadin-framework-e4703b14fdfb312b8b6d71e78d1a7f13b5e2a933.tar.gz
vaadin-framework-e4703b14fdfb312b8b6d71e78d1a7f13b5e2a933.zip
Focus click element inside a drag'n'drop wrapper (#14826)
Focus inside a drag'n'drop wrapper does not work out of the box as mousedown is cancelled to avoid text selection when starting a dnd operation. This change explicitly calls focus on the element at the location which was clicked. Input elements will now be able to gain focus but e.g. clicking to move the caret inside a text area won't work as mousedown is cancelled. Change-Id: I89e046ddb0b1044bc6a2f11fda4edbe5fda25743
Diffstat (limited to 'client/src')
-rw-r--r--client/src/com/vaadin/client/ui/VDragAndDropWrapper.java20
1 files changed, 4 insertions, 16 deletions
diff --git a/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java b/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java
index d0584d150a..15ab9a6ce0 100644
--- a/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java
+++ b/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java
@@ -45,6 +45,7 @@ import com.vaadin.client.MouseEventDetailsBuilder;
import com.vaadin.client.Util;
import com.vaadin.client.VConsole;
import com.vaadin.client.ValueMap;
+import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.dd.DDUtil;
import com.vaadin.client.ui.dd.VAbstractDropHandler;
import com.vaadin.client.ui.dd.VAcceptCallback;
@@ -106,25 +107,12 @@ public class VDragAndDropWrapper extends VCustomComponent implements
final int deltaX = Math.abs(event.getClientX() - startX);
final int deltaY = Math.abs(event.getClientY() - startY);
if ((deltaX + deltaY) < MIN_PX_DELTA) {
- setFocusOnLastElement(event);
+ Element clickedElement = WidgetUtil.getElementFromPoint(
+ event.getClientX(), event.getClientY());
+ clickedElement.focus();
}
}
- private void setFocusOnLastElement(final MouseUpEvent event) {
- Element el = event.getRelativeElement();
- getLastChildElement(el).focus();
- }
-
- private Element getLastChildElement(Element el) {
- do {
- if (el == null) {
- break;
- }
- el = el.getFirstChildElement();
- } while (el.getFirstChildElement() != null);
- return el;
- }
-
}, MouseUpEvent.getType());
addDomHandler(new TouchStartHandler() {