Problem/Motivation
My search api view configuration includes facets on taxonomy vocabularies, exposed filters for proximity search and keyword search. I have Ajax enabled. I would like users to narrow down their search using facets (in my case facet on city name) and then use exposed filter to proximity search. However, when users use exposed filters, it ignores the facet selection and returns independent results. This only happens when I use AJAX. Of course when I stop using Ajax, everything works fine.
Will really appreciate any help with this including ideas on how to fix this.
Steps to reproduce
- Create a view with Facets and exposed filters
- Use facets to narrow down search
- Use exposed filter to search
- Make sure you use Ajax
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | 3168241-15.patch | 729 bytes | n.ghunaim |
| #14 | 3168241-14.facets-plus-exposed-filters.patch | 844 bytes | jrb |
| #8 | interdiff-6_8.txt | 599 bytes | Oscaner |
| #8 | 3168241-8.patch | 1.11 KB | Oscaner |
Issue fork facets-3168241
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
arun_kv commentedComment #3
arun_kv commentedComment #4
oligerd commentedHi! I faced the same issue and i fixed it with solution
https://www.drupal.org/project/facets/issues/2986981#comment-13841967
Comment #5
andy_w commentedWe are having what looks to be the same / a similar issue and it seems to be related to the fact that when facets are embedded on the page they use a relative url (e.g. /my-page) however when they use the (incredibly useful) addExposedFiltersToFacetsUrl function which allows exposed filters and facets to operate in harmony the complete url is used, and this (for us) was throwing out a number of inbound url processors.
So our fix was to use the pathname and search aspects of window.location to ensure accessing the updateFacetsBlocks method would always give a consistent response.
I'm not sure if this is helpful, but it certainly resolved our issue, and that consistency may be worth reviewing.
Comment #6
andy_w commentedActually the above solution does not cover internet explorer
Comment #8
Oscaner commentedComment #9
qusai taha commentedPatch #8 Working fine with me and fixed the issue
Comment #10
brandonratz commentedAdditional confirmation #8 works as expected with Facets 2.0.5
Comment #11
devkinetic commentedIs this issue for 1.5 or 2.0.x ? How is this different from the solution provided in #2986981-30: Ajax facet block seems to lose Views context (filters, etc)?
Comment #12
tancPatch in #8 applies cleanly against 2.0.6 and fixes the issue I was seeing that is similar or the same as the issue in #5 with embedded facets and view with ajax enabled.
The page's path was being added to the url every time a facet was checked or unchecked. For example, on a node page containing embedded view and facets blocks with a url of
/kalender, after checking and unchecking theevents_relevant_forfacet checkbox the url would end up looking like:With this patch the url looks like this after checking and unchecking the
events_relevant_forfacet checkbox a few times:Comment #13
kaustubhb commentedI am testing this patch with the AJAX issue which is mentioned here:
But together both the patches do not seem to work,
Comment #14
jrbIn Drupal 10.1.4, the patch in #8 did not work for us. In
js/facets-views-ajax.js,options.urldid not include the facets query string variables, so they were not getting sent in the URL that Ajax uses. I'm not sure if we're seeing something different from the people that #8 worked for or if maybe something changed in D10?In our case, our facet was using the variable
oppand our exposed form had the variableskeysandopen. The URL that Ajax was using when facets were active was this (formatted for clarity):You can see that the URL there has
keysandopen, but is missing theoppvariable which was in the URL as&opp%5B0%5D=discipline%3A255&opp%5B1%5D=eligibility%3A414at this time.We were able to fix this by adding code to
Drupal.Ajax.prototype.beforeSend()that looks at the query string parameters inoptions.url, compares them those to the ones in the current URL, and adds any that are missing.That's what this patch does.
Comment #15
n.ghunaim commentedThis patch works with https://www.drupal.org/project/facets/issues/3052574#comment-15155405 and D10.
Comment #16
n.ghunaim commentedComment #17
maursilveira commentedI ran into this same issue, and the patch #14 fixes it.
Comment #18
vlyalko commentedthis https://www.drupal.org/project/facets/issues/3052574#comment-15155405 worked for me
Comment #19
shubhamsprasad commentedPatch https://www.drupal.org/project/facets/issues/3168241#comment-15261500 worked for me.
I have performed testing as well.
I have applied following patches along with it
Comment #20
shubhamsprasad commentedComment #21
lisa.rae commentedCombination of patches in #19 are not applying to:
* Drupal 10.3.2
* Facets 2.0.8
I'm using Commerce Kickstart with Demo Commerce installed for testing. Issue is present with no patches, but patches from #19 do not apply.
Moving back to Needs Work