Skip to content

Conversation

@yashikakhurana
Copy link
Contributor

Because

  • If we have more data and if filter or sort the deliveries, it takes time to get the results back based on user action on home page

This commit

  • Adds the loading spinner on home page when it is getting the request process on filtering and sorting

Fixes #14028

@yashikakhurana
Copy link
Contributor Author

Screenshot 2025-12-23 at 10 18 37 AM

Comment on lines +64 to +65
<div class="htmx-spinner" style="opacity: 0; pointer-events: none">
<i class="fa-solid fa-spinner fa-spin fa-lg text-primary"></i>
Copy link
Member

Choose a reason for hiding this comment

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

Should we perhaps put these properties on a CSS class instead of doing inline style?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah it's not a great pattern but I played around with a bunch of ways to do it and this was the least hassle

document.body.addEventListener("htmx:beforeRequest", function () {
const spinner = document.querySelector("#htmx-table-spinner");
if (spinner) {
spinner.style.opacity = "1";
}
});
document.body.addEventListener("htmx:afterRequest", function () {
const spinner = document.querySelector("#htmx-table-spinner");
if (spinner) {
spinner.style.opacity = "0";
}
});

Maybe we can poke at it again later but for the time being this is the easiest way to get it going.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah same I tried and found this one was easy

</h5>
<span class="badge rounded-pill bg-primary fs-6 px-3 py-1">{{ page_obj.paginator.count }}</span>
<div class="d-flex align-items-center gap-2">
<div class="htmx-spinner" style="opacity: 0; pointer-events: none">
Copy link
Member

Choose a reason for hiding this comment

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

likewise.

Copy link
Collaborator

@jaredlockhart jaredlockhart left a comment

Choose a reason for hiding this comment

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

Tested locally, works great, thnx @yashikakhurana 🙏

Comment on lines +64 to +65
<div class="htmx-spinner" style="opacity: 0; pointer-events: none">
<i class="fa-solid fa-spinner fa-spin fa-lg text-primary"></i>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah it's not a great pattern but I played around with a bunch of ways to do it and this was the least hassle

document.body.addEventListener("htmx:beforeRequest", function () {
const spinner = document.querySelector("#htmx-table-spinner");
if (spinner) {
spinner.style.opacity = "1";
}
});
document.body.addEventListener("htmx:afterRequest", function () {
const spinner = document.querySelector("#htmx-table-spinner");
if (spinner) {
spinner.style.opacity = "0";
}
});

Maybe we can poke at it again later but for the time being this is the easiest way to get it going.

@yashikakhurana yashikakhurana added this pull request to the merge queue Jan 5, 2026
Merged via the queue into main with commit dc46688 Jan 5, 2026
17 checks passed
@yashikakhurana yashikakhurana deleted the 14028 branch January 5, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add loading spinner to home page

4 participants