fix(ui): release: set default release title to tag name ()

This fixes a regression bug introduced in the new feature added by 

Currently the validation will fail if you keep the default added release title.

The test was changed to fail without the fix.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6883
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Co-authored-by: Beowulf <beowulf@beocode.eu>
Co-committed-by: Beowulf <beowulf@beocode.eu>
This commit is contained in:
Beowulf 2025-02-23 08:30:39 +00:00 committed by Earl Warren
parent de3e6f8a72
commit b88baac7e3
2 changed files with 6 additions and 3 deletions
tests/e2e
web_src/js/features

View file

@ -30,8 +30,7 @@ test('External Release Attachments', async ({page, isMobile}) => {
await validate_form({page}, 'fieldset'); await validate_form({page}, 'fieldset');
const textarea = page.locator('input[name=tag_name]'); const textarea = page.locator('input[name=tag_name]');
await textarea.pressSequentially('2.0'); await textarea.pressSequentially('2.0');
await expect(page.locator('input[name=title]')).toHaveAttribute('placeholder', '2.0'); await expect(page.locator('input[name=title]')).toHaveValue('2.0');
await page.fill('input[name=title]', '2.0');
await page.click('#add-external-link'); await page.click('#add-external-link');
await page.click('#add-external-link'); await page.click('#add-external-link');
await page.fill('input[name=attachment-new-name-2]', 'Test'); await page.fill('input[name=attachment-new-name-2]', 'Test');

View file

@ -32,6 +32,7 @@ function initTagNameEditor() {
const newTagHelperText = el.getAttribute('data-tag-helper-new'); const newTagHelperText = el.getAttribute('data-tag-helper-new');
const existingTagHelperText = el.getAttribute('data-tag-helper-existing'); const existingTagHelperText = el.getAttribute('data-tag-helper-existing');
let previousTag = '';
document.getElementById('tag-name').addEventListener('keyup', (e) => { document.getElementById('tag-name').addEventListener('keyup', (e) => {
const value = e.target.value; const value = e.target.value;
const tagHelper = document.getElementById('tag-helper'); const tagHelper = document.getElementById('tag-helper');
@ -45,7 +46,10 @@ function initTagNameEditor() {
} }
const title_input = document.getElementById('release-title'); const title_input = document.getElementById('release-title');
title_input.placeholder = value; if (!title_input.value || previousTag === title_input.value) {
title_input.value = value;
}
previousTag = value;
}); });
} }