Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add loading status to submit buttons #10459

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2612,6 +2612,14 @@ $(document).ready(async () => {
}
});

$('form.ui.form button').click(function () {
const $this = $(this);
$this.addClass('loading');
setTimeout(() => {
$this.removeClass('loading');
}, 1000 * 5); // 5 seconds
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should enable the button only after received the HTTP response.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this only applies to "real" forms, in which case receiving a response means the page is reloading I think?

This timeout is a fallback in case it fails so the button isn't stuck perpetually loading.

});

// parallel init of lazy-loaded features
[hljs] = await Promise.all([
initHighlight(),
Expand Down
4 changes: 4 additions & 0 deletions web_src/less/_base.less
Original file line number Diff line number Diff line change
Expand Up @@ -1217,3 +1217,7 @@ i.icon.centerlock {
.ui.attached.segment + .ui.attached.header {
margin-top: 1rem;
}

button.loading {
pointer-events: none !important;
}