aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VComboBox.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxPasteFilter.java66
2 files changed, 69 insertions, 1 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VComboBox.java b/client/src/main/java/com/vaadin/client/ui/VComboBox.java
index 81453bfade..3c2f599300 100644
--- a/client/src/main/java/com/vaadin/client/ui/VComboBox.java
+++ b/client/src/main/java/com/vaadin/client/ui/VComboBox.java
@@ -28,6 +28,7 @@ import java.util.logging.Logger;
import com.google.gwt.animation.client.AnimationScheduler;
import com.google.gwt.aria.client.Roles;
import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.core.client.Scheduler;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
@@ -1850,7 +1851,8 @@ public class VComboBox extends Composite implements Field, KeyDownHandler,
if (event.getTypeInt() == Event.ONPASTE) {
if (textInputEnabled && connector.isEnabled()
&& !connector.isReadOnly()) {
- filterOptions(currentPage);
+ Scheduler.get()
+ .scheduleDeferred(() -> filterOptions(currentPage));
}
}
}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxPasteFilter.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxPasteFilter.java
new file mode 100644
index 0000000000..ba36c69d73
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxPasteFilter.java
@@ -0,0 +1,66 @@
+package com.vaadin.tests.components.combobox;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.vaadin.data.provider.ListDataProvider;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.Label;
+
+public class ComboBoxPasteFilter extends AbstractTestUI {
+
+ private static final String WORDS = "loutish offer popcorn bitter buzz "
+ + "change mass boy erect aquatic donkey gentle colorful zippy "
+ + "soup pocket bathe fear supreme pan present knife quartz shy "
+ + "conscious tested thumb snow evasive reason dusty bridge giddy "
+ + "smooth bomb endurable tiger red gun fix regret quizzical income "
+ + "careless owe sleet loss silent serious play consider messy "
+ + "retire reduce shaky shiny low suggest preach bleach drunk "
+ + "talk instruct peck hungry improve meat chop title encourage "
+ + "marry island romantic fabulous kneel guarantee dock complain "
+ + "mate tour intend geese hole swing mine superb level slip "
+ + "spoon sky live nine open playground guard possible hate "
+ + "spotless apparatus bow";
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ ComboBox<String> box = new ComboBox<String>("Paste a word from below");
+ Collection<String> massiveData = massiveData();
+ box.setDataProvider(new ListDataProvider<String>(massiveData));
+ addComponent(box);
+
+ Label label = new Label(WORDS);
+ label.setSizeFull();
+ addComponent(label);
+ }
+
+ private Collection<String> massiveData() {
+ return find(WORDS, "([\\w]+)");
+ }
+
+ public List<String> find(String text, String patternStr) {
+ Pattern pattern = Pattern.compile(patternStr);
+ Matcher matcher = pattern.matcher(text);
+ List<String> result = new ArrayList<>();
+ while (matcher.find()) {
+ result.add(matcher.group());
+ }
+ return result;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 11779;
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "ComboBox should filter regardless of whether the value is "
+ + "pasted with keyboard or with mouse";
+ }
+}