prevent double click new issue/pull/comment button (#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 <1012112796@qq.com>
This commit is contained in:
a1012112796 2022-05-07 20:24:02 +08:00 committed by GitHub
parent 0eac09e066
commit 672e5a752d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View File

@ -20,7 +20,7 @@
</div> </div>
{{template "repo/issue/comment_tab" .}} {{template "repo/issue/comment_tab" .}}
<div class="text right"> <div class="text right">
<button class="ui green button" tabindex="6"> <button class="ui green button loading-button" tabindex="6">
{{if .PageIsComparePull}} {{if .PageIsComparePull}}
{{.i18n.Tr "repo.pulls.create"}} {{.i18n.Tr "repo.pulls.create"}}
{{else}} {{else}}

View File

@ -121,7 +121,7 @@
</div> </div>
{{end}} {{end}}
{{end}} {{end}}
<button class="ui green button" tabindex="5"> <button class="ui green button loading-button" tabindex="5">
{{.i18n.Tr "repo.issues.create_comment"}} {{.i18n.Tr "repo.issues.create_comment"}}
</button> </button>
</div> </div>
@ -172,7 +172,7 @@
</div> </div>
{{end}} {{end}}
{{end}} {{end}}
<button class="ui green button" tabindex="5"> <button class="ui green button loading-button" tabindex="5">
{{.i18n.Tr "repo.issues.create_comment"}} {{.i18n.Tr "repo.issues.create_comment"}}
</button> </button>
</div> </div>

View File

@ -142,6 +142,18 @@ export function initGlobalCommon() {
window.location = href; window.location = href;
} }
}); });
// loading-button this logic used to prevent push one form more than one time
$(document).on('click', '.button.loading-button', function (e) {
const $btn = $(this);
if ($btn.hasClass('loading')) {
e.preventDefault();
return false;
}
$btn.addClass('loading disabled');
});
} }
export function initGlobalDropzone() { export function initGlobalDropzone() {