Skip to content

The Unified and Autonomous Development Platform

fix: Unable to edit fields from issue list

Robin Shen8429586052cf
diff --git a/e2e-test/tests/edit-issue-field-from-list.spec.js b/e2e-test/tests/edit-issue-field-from-list.spec.js
new file mode 100644
index 0000000000..708159fb26
--- /dev/null
+++ b/e2e-test/tests/edit-issue-field-from-list.spec.js
@@ -0,0 +1,25 @@
+import { expect, test } from '@playwright/test';
+import { createProject, login, openIssue } from './helpers.js';
+
+test('admin can edit an issue field from the issue list', async ({ page }) => {
+ test.setTimeout(60_000);
+
+ const indicatorErrors = [];
+ page.on('console', (message) => {
+ if (message.type() === 'error' && message.text().includes('successIndicatorTimeout')) {
+ indicatorErrors.push(message.text());
+ }
+ });
+
+ await login(page, 'admin', 'admin');
+ const projectName = await createProject(page);
+ await openIssue(page, projectName);
+
+ await page.goto(`${projectName}/~issues`);
+ const field = page.locator('tr.issue .field-values.editable').first();
+ await expect(field).toBeVisible();
+ await field.click();
+
+ expect(indicatorErrors).toEqual([]);
+ await expect(page.locator('.floating.inplace-property-edit')).toBeVisible();
+});
diff --git a/server-core/src/main/java/io/onedev/server/web/ajaxlistener/AttachAjaxIndicatorListener.java b/server-core/src/main/java/io/onedev/server/web/ajaxlistener/AttachAjaxIndicatorListener.java
index d337a78a69..e668312696 100644
--- a/server-core/src/main/java/io/onedev/server/web/ajaxlistener/AttachAjaxIndicatorListener.java
+++ b/server-core/src/main/java/io/onedev/server/web/ajaxlistener/AttachAjaxIndicatorListener.java
@@ -65,9 +65,11 @@ public class AttachAjaxIndicatorListener implements IAjaxCallListener {
String insertAt = attachMode==AttachMode.APPEND?"after":"before";
return String.format(""
+ "var $attachTo = $('#%s');"
+ + "if ($attachTo.length != 0) {"
+ "clearTimeout($attachTo[0].successIndicatorTimeout);"
+ "$attachTo.siblings('.working-indicator').remove(); "
- + "$attachTo.addClass('with-working-indicator').%s('<img src=\"%s\" width=\"16\" height=\"16\" class=\"working-indicator\"></img>');",
+ + "$attachTo.addClass('with-working-indicator').%s('<img src=\"%s\" width=\"16\" height=\"16\" class=\"working-indicator\"></img>');"
+ + "}",
attachTo.getMarkupId(), insertAt, url);
}
@@ -85,12 +87,14 @@ public class AttachAjaxIndicatorListener implements IAjaxCallListener {
String insertAt = attachMode==AttachMode.APPEND?"after":"before";
return String.format(""
+ "var $attachTo = $('#%s');"
+ + "if ($attachTo.length != 0) {"
+ "clearTimeout($attachTo[0].successIndicatorTimeout);"
+ "$attachTo.removeClass('with-working-indicator').siblings('.working-indicator').remove();"
+ "$attachTo.%s('<svg class=\"icon working-indicator text-success\"><use xlink:href=\"%s\"/></svg>');"
+ "$attachTo[0].successIndicatorTimeout = setTimeout(function() {"
+ "$attachTo.siblings('.working-indicator').remove();"
- + "}, 1000);",
+ + "}, 1000);"
+ + "}",
attachTo.getMarkupId(), insertAt,
SpriteImage.getVersionedHref(IconScope.class, "tick"));
} else {