summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorTatu Lund <tatu@vaadin.com>2021-02-16 13:16:49 +0200
committerGitHub <noreply@github.com>2021-02-16 13:16:49 +0200
commitb3d80da9b422360ad99e4a29c3dc1d9ad4ce7d1c (patch)
tree80d6c3fbb415897626eaa4118736d170d5bf8542 /client
parentf46362a731ce459d4afa7d79f60468ec72fda4ba (diff)
downloadvaadin-framework-b3d80da9b422360ad99e4a29c3dc1d9ad4ce7d1c.tar.gz
vaadin-framework-b3d80da9b422360ad99e4a29c3dc1d9ad4ce7d1c.zip
fix: Focus-activated shortcut listener in compatibility TextField (#12203)
Diffstat (limited to 'client')
-rw-r--r--client/src/main/java/com/vaadin/client/ui/ShortcutActionHandler.java28
1 files changed, 23 insertions, 5 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/ShortcutActionHandler.java b/client/src/main/java/com/vaadin/client/ui/ShortcutActionHandler.java
index 1c03a2719d..92c26d2b70 100644
--- a/client/src/main/java/com/vaadin/client/ui/ShortcutActionHandler.java
+++ b/client/src/main/java/com/vaadin/client/ui/ShortcutActionHandler.java
@@ -127,30 +127,48 @@ public class ShortcutActionHandler {
}
final ComponentConnector finalTarget = target;
event.preventDefault();
+
/*
* The focused component might have unpublished changes, try to
* synchronize them before firing shortcut action.
*/
- client.flushActiveConnector();
- /*
- * Legacy components don't have built-in logic for flushing, they need a
- * workaround with blur and focus to trigger the value change.
- */
+ boolean flushed = false;
ComponentConnector activeConnector = getActiveConnector(client);
+
if (activeConnector != null) {
Class<?> clz = activeConnector.getClass();
while (clz != null) {
if (clz.getName().equals(
+ "com.vaadin.v7.client.ui.textfield.TextFieldConnector")) {
+ /*
+ * Legacy textfields support modern flushing.
+ */
+ client.flushActiveConnector();
+ flushed = true;
+ break;
+ }
+ if (clz.getName().equals(
"com.vaadin.v7.client.ui.AbstractLegacyComponentConnector")) {
+ /*
+ * Most of the legacy components don't have built-in logic
+ * for flushing, they need a workaround with blur and focus
+ * to trigger the value change.
+ */
shakeTarget(et);
Scheduler.get().scheduleDeferred(() -> {
shakeTarget(et);
});
+ flushed = true;
break;
}
clz = clz.getSuperclass();
}
}
+ if (!flushed) {
+ // Use V8 style flushing for the rest.
+ client.flushActiveConnector();
+ }
+
Scheduler.get().scheduleDeferred(() -> {
if (finalTarget != null) {
client.updateVariable(paintableId, "actiontarget", finalTarget,