summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2024-05-17 09:07:09 +0800
committerGitHub <noreply@github.com>2024-05-17 01:07:09 +0000
commitbd3787c774adbbb0c7df834f5d4615dc795e7f6c (patch)
tree7bc57e2ba248bcf74af1dda079a641e19bda413a
parentf0e74da71929196dfdcab48616303d8b1c2c30da (diff)
downloadgitea-bd3787c774adbbb0c7df834f5d4615dc795e7f6c.tar.gz
gitea-bd3787c774adbbb0c7df834f5d4615dc795e7f6c.zip
Fix JS error when editing a merged PR's title (#30990) (#31001)
Backport #30990 by @wxiaoguang Regression of Fix issue/PR title edit (#30858) Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
-rw-r--r--templates/repo/issue/view_title.tmpl6
-rw-r--r--web_src/js/features/repo-issue.js5
2 files changed, 6 insertions, 5 deletions
diff --git a/templates/repo/issue/view_title.tmpl b/templates/repo/issue/view_title.tmpl
index 4415ad79f5..097d7b1f7c 100644
--- a/templates/repo/issue/view_title.tmpl
+++ b/templates/repo/issue/view_title.tmpl
@@ -26,9 +26,7 @@
</div>
<div class="issue-title-buttons">
<button class="ui small basic cancel button">{{ctx.Locale.Tr "repo.issues.cancel"}}</button>
- <button class="ui small primary button"
- data-update-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/title"
- {{if .Issue.IsPull}}data-target-update-url="{{$.RepoLink}}/pull/{{.Issue.Index}}/target_branch"{{end}}>
+ <button class="ui small primary button" data-update-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/title">
{{ctx.Locale.Tr "repo.issues.save"}}
</button>
</div>
@@ -77,7 +75,7 @@
{{ctx.Locale.Tr "repo.pulls.title_desc" .NumCommits $headHref $baseHref}}
</span>
{{end}}
- <span id="pull-desc-editor" class="tw-hidden flex-text-block">
+ <span id="pull-desc-editor" class="tw-hidden flex-text-block" data-target-update-url="{{$.RepoLink}}/pull/{{.Issue.Index}}/target_branch">
<div class="ui floating filter dropdown">
<div class="ui basic small button tw-mr-0">
<span class="text">{{ctx.Locale.Tr "repo.pulls.compare_compare"}}: {{$.HeadTarget}}</span>
diff --git a/web_src/js/features/repo-issue.js b/web_src/js/features/repo-issue.js
index 8ee681aedc..519db34934 100644
--- a/web_src/js/features/repo-issue.js
+++ b/web_src/js/features/repo-issue.js
@@ -626,9 +626,12 @@ export function initRepoIssueTitleEdit() {
showElem(issueTitleDisplay);
showElem('#pull-desc-display');
});
+
+ const pullDescEditor = document.querySelector('#pull-desc-editor'); // it may not exist for a merged PR
+ const prTargetUpdateUrl = pullDescEditor?.getAttribute('data-target-update-url');
+
const editSaveButton = issueTitleEditor.querySelector('.ui.primary.button');
editSaveButton.addEventListener('click', async () => {
- const prTargetUpdateUrl = editSaveButton.getAttribute('data-target-update-url');
const newTitle = issueTitleInput.value.trim();
try {
if (newTitle && newTitle !== oldTitle) {