feat: show spinner when loading content history menu (#9874)

- When clicking on the content history menu "edited" item, show a spinner animation as before the dropdown is show can take a measurable amount of time.
- We cannot rely on fomantic adding the loading indicator (although it does have this capability), it only adds this indicator when waiting for the network request. For a fast Forgejo instance waiting for the network response is faster than what fomantic is doing to prepare the dropdown.
- Resolves forgejo/forgejo#9841

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9874
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
Gusted 2025-10-27 22:04:04 +01:00 committed by Gusted
commit 4cb72644d3
2 changed files with 82 additions and 25 deletions

View file

@ -102,6 +102,15 @@ function showContentHistoryMenu(issueBaseUrl, $item, commentId) {
$headerLeft.find(`.content-history-menu`).remove();
$headerLeft.append($(menuHtml));
// Should be run before fomantic's dropdown component.
$headerLeft.find('.dropdown').on('click', function (ev) {
if (ev.target !== this || this.classList.contains('active')) {
return;
}
this.classList.add('is-loading');
});
$headerLeft.find('.dropdown').dropdown({
action: 'hide',
apiSettings: {
@ -117,6 +126,9 @@ function showContentHistoryMenu(issueBaseUrl, $item, commentId) {
showContentHistoryDetail(issueBaseUrl, commentId, value, itemHtml);
}
},
onShow() {
this.classList.remove('is-loading');
},
});
}