diff --git a/templates/repo/issue/milestone/select_menu.tmpl b/templates/repo/issue/milestone/select_menu.tmpl
index eae2f3baa9..570acc2eee 100644
--- a/templates/repo/issue/milestone/select_menu.tmpl
+++ b/templates/repo/issue/milestone/select_menu.tmpl
@@ -1,3 +1,4 @@
+{{$useHTMX := not .NewIssuePage}}
{{if or .OpenMilestones .ClosedMilestones}}
{{svg "octicon-search" 16}}
@@ -5,7 +6,7 @@
{{end}}
-{{ctx.Locale.Tr "repo.issues.new.clear_milestone"}}
+{{ctx.Locale.Tr "repo.issues.new.clear_milestone"}}
{{if and (not .OpenMilestones) (not .ClosedMilestones)}}
{{ctx.Locale.Tr "repo.issues.new.no_items"}}
@@ -17,7 +18,7 @@
{{ctx.Locale.Tr "repo.issues.new.open_milestone"}}
{{range .OpenMilestones}}
-
+
{{svg "octicon-milestone" 16 "tw-mr-1"}}
{{.Name}}
@@ -29,7 +30,7 @@
{{ctx.Locale.Tr "repo.issues.new.closed_milestone"}}
{{range .ClosedMilestones}}
-
+
{{svg "octicon-milestone" 16 "tw-mr-1"}}
{{.Name}}
diff --git a/templates/repo/issue/new_form.tmpl b/templates/repo/issue/new_form.tmpl
index 465cb44f6f..fe10c1f9b9 100644
--- a/templates/repo/issue/new_form.tmpl
+++ b/templates/repo/issue/new_form.tmpl
@@ -64,7 +64,7 @@
{{end}}
diff --git a/tests/e2e/issue-sidebar.test.e2e.js b/tests/e2e/issue-sidebar.test.e2e.js
index 3bda7bdd17..0311910a34 100644
--- a/tests/e2e/issue-sidebar.test.e2e.js
+++ b/tests/e2e/issue-sidebar.test.e2e.js
@@ -119,3 +119,25 @@ test('Issue: Milestone', async ({browser}, workerInfo) => {
await expect(selectedMilestone).toContainText('No milestone');
await expect(page.locator('.timeline-item.event').last()).toContainText('user2 removed this from the milestone1 milestone');
});
+
+test('New Issue: Milestone', async ({browser}, workerInfo) => {
+ test.skip(workerInfo.project.name === 'Mobile Safari', 'Unable to get tests working on Safari Mobile, see https://codeberg.org/forgejo/forgejo/pulls/3445#issuecomment-1789636');
+ const page = await login({browser}, workerInfo);
+
+ const response = await page.goto('/user2/repo1/issues/new');
+ await expect(response?.status()).toBe(200);
+
+ const selectedMilestone = page.locator('.issue-content-right .select-milestone.list');
+ const milestoneDropdown = page.locator('.issue-content-right .select-milestone.dropdown');
+ await expect(selectedMilestone).toContainText('No milestone');
+
+ // Add milestone.
+ await milestoneDropdown.click();
+ await page.getByRole('option', {name: 'milestone1'}).click();
+ await expect(selectedMilestone).toContainText('milestone1');
+
+ // Clear milestone.
+ await milestoneDropdown.click();
+ await page.getByText('Clear milestone', {exact: true}).click();
+ await expect(selectedMilestone).toContainText('No milestone');
+});
diff --git a/web_src/js/features/repo-legacy.js b/web_src/js/features/repo-legacy.js
index d9aa881127..b25fc28dea 100644
--- a/web_src/js/features/repo-legacy.js
+++ b/web_src/js/features/repo-legacy.js
@@ -270,7 +270,9 @@ export function initRepoCommentForm() {
}
let icon = '';
- if (input_id === '#project_id') {
+ if (input_id === '#milestone_id') {
+ icon = svg('octicon-milestone', 18, 'tw-mr-2');
+ } else if (input_id === '#project_id') {
icon = svg('octicon-project', 18, 'tw-mr-2');
} else if (input_id === '#assignee_id') {
icon = `
`;
@@ -311,6 +313,7 @@ export function initRepoCommentForm() {
// Milestone, Assignee, Project
selectItem('.select-project', '#project_id');
+ selectItem('.select-milestone', '#milestone_id');
selectItem('.select-assignee', '#assignee_id');
}