Skip to content

Commit 017ec2a

Browse files
a1012112796AbdulrhmnGhanem
authored andcommitted
prevent double click new issue/pull/comment button (go-gitea#16157)
* prevent double click new issue/pull/comment button when network is not good, these button maybe double clicked, then more than one same issues pulls or comments will be created. this pull request will fix this bug. Signed-off-by: a1012112796 <[email protected]>
1 parent f2962da commit 017ec2a

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

templates/repo/issue/new_form.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</div>
2121
{{template "repo/issue/comment_tab" .}}
2222
<div class="text right">
23-
<button class="ui green button" tabindex="6">
23+
<button class="ui green button loading-button" tabindex="6">
2424
{{if .PageIsComparePull}}
2525
{{.i18n.Tr "repo.pulls.create"}}
2626
{{else}}

templates/repo/issue/view_content.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
</div>
122122
{{end}}
123123
{{end}}
124-
<button class="ui green button" tabindex="5">
124+
<button class="ui green button loading-button" tabindex="5">
125125
{{.i18n.Tr "repo.issues.create_comment"}}
126126
</button>
127127
</div>
@@ -172,7 +172,7 @@
172172
</div>
173173
{{end}}
174174
{{end}}
175-
<button class="ui green button" tabindex="5">
175+
<button class="ui green button loading-button" tabindex="5">
176176
{{.i18n.Tr "repo.issues.create_comment"}}
177177
</button>
178178
</div>

web_src/js/features/common-global.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,18 @@ export function initGlobalCommon() {
142142
window.location = href;
143143
}
144144
});
145+
146+
// loading-button this logic used to prevent push one form more than one time
147+
$(document).on('click', '.button.loading-button', function (e) {
148+
const $btn = $(this);
149+
150+
if ($btn.hasClass('loading')) {
151+
e.preventDefault();
152+
return false;
153+
}
154+
155+
$btn.addClass('loading disabled');
156+
});
145157
}
146158

147159
export function initGlobalDropzone() {

0 commit comments

Comments
 (0)