Skip to content

The Unified and Autonomous Development Platform

fix issue #206 - Unable to assing pull request reviewer

Robin Shena4860b98e2c4
diff --git a/server-core/src/main/java/io/onedev/server/web/component/select2/SelectToAddChoice.java b/server-core/src/main/java/io/onedev/server/web/component/select2/SelectToAddChoice.java
index 87b8b523d6..b803264a3c 100644
--- a/server-core/src/main/java/io/onedev/server/web/component/select2/SelectToAddChoice.java
+++ b/server-core/src/main/java/io/onedev/server/web/component/select2/SelectToAddChoice.java
@@ -1,6 +1,7 @@
package io.onedev.server.web.component.select2;
import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.model.IModel;
@SuppressWarnings("serial")
@@ -39,6 +40,19 @@ public abstract class SelectToAddChoice<T> extends Select2Choice<T> {
protected void onInitialize() {
super.onInitialize();
+ add(new AjaxFormComponentUpdatingBehavior("change") {
+
+ @Override
+ protected void onUpdate(AjaxRequestTarget target) {
+ if (selection != null) {
+ onSelect(target, selection);
+ selection = null;
+ }
+ String script = String.format("setTimeout(function(){$('#%s').select2('data', null);}, 0);", getMarkupId());
+ target.appendJavaScript(script);
+ }
+
+ });
setOutputMarkupId(true);
}