Repository navigation
Add HTMX to listing filters - #462
Merged
Merged
Conversation
added 7 commits
September 24, 2026 10:44
Give the results list, pagination and active-filter pills stable ids so they can be swapped in place, add a visually hidden result count status message, and add data attributes the listing-filters JS can use to find the submit button, pills and clear-all link.
Pill and "Clear all" clicks now untick the matching checkboxes and fire a single change event, so HTMX stays the only request path. Their hrefs are kept as the no-JS fallback. Focus moves to the next pill, then the previous pill, then the first dropdown toggle once the new pills are swapped in. The results list is marked aria-busy while a request is in flight.
jhancock532
marked this pull request as ready for review
September 24, 2026 10:27
helenb
reviewed
Sep 25, 2026
Contributor
Author
|
Thank you @helenb, I've made a small fix
From looking into this, this is just from missing images and is the default Wagtail behaviour, with & without HTMX. In the screenshot above, it looks like we see the same 404 error when the page is first loaded as normal HTML, and then again with the HTMX reloads. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Description
The filters on the Blog, Events and Work listing pages now update the results as soon as a checkbox changes. Users no longer have to click "Apply filters". All three pages share the same filter component, so most of the change is in one template and one JS component.
Technical details
HTMX requests get the full page, and
hx-selectpicks out the parts to swap. This avoids new views and partial templates, at the cost of sending more HTML than a partial would. This reduces the complexity of the MR significantly so I think it is a worthwhile tradeoff.The browser back and forward buttons do a full page load (I've set the HTMX
historyCacheSize = 0), because HTMX's history restore would leave the site's JS components unbound.There's no debounce.
hx-sync="this:replace"cancels any request in flight, so only the last request is shown.HTMX loads on every page from
main.js(about 16 KB gzipped), withallowEvaland indicator styles turned off for CSP. I've chosen an easier to review implementation here over the more complex approach that would result in minor sustainability improvements.Caching considerations
Removing HX-Current-URL from the Cloudflare cache key. I've left this out because I'm not fully sure of the implications of updating a Cloudflare worker. As I understand it, the worker adds
HX-Current-URL(the URL of the page the user is on when they make the request) to the cache key for HTMX requests. So when a user changes a filter, the response is cached against both the URL they came from and the new filtered URL. If visitors filter in different sequences, most of these requests will miss the cache and go to the origin.For example:
A user follows a link to
/news/?sector=charity-non-profit&service=design. This is a normal page load, so it's cached as usual and other visitors to that URL get the cached copy.The user then removes a filter, which makes an HTMX request for
/news/?sector=charity-non-profit. That response is cached against both/news/?sector=charity-non-profit&service=designand/news/?sector=charity-non-profit, so another visitor only gets it from the cache if they make exactly the same change. A direct visit to/news/?sector=charity-non-profitisn't affected, because it has no HX headers.Users won't see incorrect results, since every cached copy is correct for its URL. The cost is more requests reaching the origin than necessary. I don't think it's a major concern, but would be nice to update / redeploy the worker to remove
HX-Current-URLif that's OK.Other considerations
How to Test
On each of Blog, Events and Work:
Plese check out the pattern library template as well: http://localhost:8000/pattern-library/pattern/patterns/molecules/listing-filters/listing-filters.html
Screenshots
Expand to see more
JS disabled - Apply filters button shows
JS enabled, light mode - No apply filters button shows
MR Checklist
Unit tests
Documentation
Browser testing
Data protection
Light and dark mode
Accessibility
Sustainability
Pattern library