Until we model Facets as Views exposed filters, Facets and Views always have an impedance mismatch. (Also see #2957950: Add views area plugin)
So we currently have 28 and counting Facets / Ajax issues. Here's a try of an overview.
How facets identifies the block to be updated in ajax
* #3052574: Facets with AJAX not working in most of situations has a fairly elaborated patch that overhauls server-side generation and client-side recognition of facet block identifier and lets ajax grip on any non-core placed block
* #3012041-8: The introduction of AJAX facets breaks all facets using the checkbox-widget has a small patch that adds some block selector parsing server-side
* #3013795: Robustify how ajax finds the facet block has a fairly elaborated patch that overhauls client-side finding of the ajax facet block
* #3071885: Facets with AJAX fails with JS error has a fairly elaborated but "not currently working" clientside patch
* #3012531: Ajax Facets do not support Range Slider has a patch that add some clientside finding of blocks
* Special case empty facets: #2989943: Ajax facets should render anything
* #3034918: Add Range Input View Update to facets-views-ajax.js has a patch that clientside excludes range blocks
Lost arguments and query parameters
* #3058314: Facets lost when search term changes, only with ajax
* #3106111: Facets compatibility with views_ajax_history
* #2986981-13: Ajax facet block seems to lose Views context (filters, etc) has a server side ajax patch that amends views contextual arguments
* (same issue) #2986981-5: Ajax facet block seems to lose Views context (filters, etc) has a serverside code snippet that amends query parameters
* #3014227: Facets should update the current request facets query params on ajax calls. has a patch that clientside adds query parameters
Excess arguments and query parameters
* #3070461: Facet links in modal popup break has a trivial RTBC patch that removes the _wrapper_format parameter server-side
* #3064575: "page" parameter showing up in facet URLs
Miscellaneous
* #2986590: Allow to override view display ajax behavior for the facet block seems to propose to add a setting if facets should participate in ajax
* #3039276: FacetBlockAjaxController needs to make usage of DefaultFacetManager proposes a way to fix lost attachments
* #3002132: Summary block broken
* #3028716: When a URL segment matches possible language the facet breaks
* #2997417: Navigating back in browser doesn't update view with Ajax facets
* #2976602: Improve performance of render facet
* #3004867: Refresh div after having clicked on an item of a facet block
* infinite_scroll_views #3053023: Views infinite scroll is not working properly with facets
* #3160406: Exposed forms with checkboxes don't work correctly if the checkbox value is in the URL Core checkbox problems
* #3296120: Facets with ajax enabled and no source path results in /views/ajax?f... urls
Comments
Comment #2
borisson_Yeah, facets with ajax were a mistake - I shouldn't have committed that patch without adding a ton of extra tests and fixed the results.
We can't model them as exposed filters because we don't support just views (see search api page or basically anything that is a Search API display).
Comment #3
geek-merlinComment #4
swentel commentedfwiw, I created #3073444: Create views plugins to render facets and summaries in filters and areas - I understand the need for support for ajax since it's not only views, although, in a way, I would argue that having it only work within views would be fine imo. You wouldn't have to care about all the weird things happening in ajax since views does all the heavy lifting. Let me know if you would still be up for that exposed filter. Afaics, it will only be PHP code anyway.
Of course, since it's in, you're kind of stuck with it now - unless it's only dev, haven't checked, in that case, revert it now :)
Comment #5
geek-merlinOK i hope this contributes to sorting things out. (Bear with me if i fucked up any of the gazillion issue number copy-pastes...)
Comment #6
geek-merlin> We can't model them as exposed filters because we don't support just views
I see. Any chance to refactor to get a exposed-filter like API instead of the two systems hacking each other? @swentel is your idea going into the same direction?
Comment #7
anruetherComment #8
borisson_Yeah I guess supporting only views for ajax would be something that is easy enough to justify.
The idea to use an exposed filter would probably resolve some of the issues. I'm just hoping it doesn't introduce new ones.
It's been in for at least a year, so too late for a revert ;)
Comment #9
swentel commentedA crap :)
I'm already working on a patch, I'll upload it as soon as I have something working.
Comment #10
bgronek commentedHonestly I find this huge list of issues a bit strange. We are using facets in a few projects with Ajax and it's working quite well.
In order to get it to work properly, we have had to structure our search page view, exposed filter form and facets carefully using the core block layout mechanism.
Comment #11
damienmckennaFor what it's worth, on a simple view with a single facet, the AJAX integration from #3073444: Create views plugins to render facets and summaries in filters and areas works, though I'm also using Better Exposed Filters.
Comment #12
pcambraComment #13
acThis could also be included in the list: https://www.drupal.org/project/facets/issues/3204660
Comment #14
neclimdulComment #15
harcher commentedThe facets module does not work with Ajax.
There are many issues regarding Facets + Ajax, and tens of patches being submitted. I just updated to Facets 2.0 (on Drupal 9.2.10) and my view pages with facet blocks are not working. Various js errors in the console. This is also the case with a fresh clean Drupal setup. I am having to go back into all the various patches/issues and find something that works with the latest Facets 2.0. Nothing works.
Even though this is an open source project there must be a better way to manage this. This functionality is very common and is to be expected especially from a powerful platform such as Drupal.
I am prepared to help. If a maintainer wants to discuss this with me and how I can help then I am all ears. But right now, it may not be worth planning to use drupal for any website requiring facet/filtering functionality, which most do.
Comment #16
strykaizer@hga77 We can always use extra help. Feel free to join #search in the drupal slack and let us know how you want to help.
While most of the contributors lack time, ajax is a high priorityfor us, now that most other features are stable.
Comment #17
mkalkbrennerComment #18
anybodyChanged priority to major for this META issue to point out the importance of this issue, having several child issues reporting problems.
Comment #19
geek-merlinRaised prio of #3073444: Create views plugins to render facets and summaries in filters and areas, as this issue is a meta and not actionable itself.
Comment #20
shabana.navas commentedI'm currently using the latest 2.0 version of Facets (2.0.6) and I'm forced to render my facets in my view page via twig:
Rendering the facets this way doesn't work with Ajax and exposed filters. I've got BEF and whenever I try to sort or filter, the facets disappear. It loads fine on initial page load, after that it just disappears. Rendering the facet via the Block UI works just fine and the facets persist after each ajax request.
I've added tried the following different patches:
https://www.drupal.org/project/facets/issues/3052574
https://www.drupal.org/project/facets/issues/3013795
But none of them have fixed the issue. Any ideas on what could be wrong?
Comment #21
sneha_surve commentedcan someone help me with this issue : https://www.drupal.org/project/facets/issues/3350613
Comment #22
duaelfr