- Merge request !26Issue #3052574: Facets with AJAX not working in most of situations โ (Open) created by eduardo morales alberti
- Merge request !113Draft: Issue #3052574: Facets with AJAX not working in most of situations โ (Open) created by eduardo morales alberti
- Status changed to Needs review
almost 2 years ago 3:35pm 1 February 2023 - ๐ง๐ชBelgium jmaerckaert Geer, province of Liรจge
I did a patch for version 2.0.6.
The former one was not working for this version. - ๐ง๐ชBelgium jmaerckaert Geer, province of Liรจge
Fix a bug in Facets Summary. The facet was not displaying anymore.
- ๐ท๐ดRomania bogdan.dinu
I updated the patch to make it work for views embeded as blocks. The pushstate was changing the URL to the views page URL.
I've added support for pushstate navigation. The reload workaround only worked for one history iteration.
I've also included @jmaerckaert's latest update for the facets summary. - ๐บ๐ธUnited States mrweiner
Just a note that you may also need https://www.drupal.org/project/drupal/issues/3132456 ๐ Views Ajax issue on deleting instances Needs work to handle some scenarios.
- ๐ง๐ชBelgium JeroenT ๐ง๐ช
Not sure if this should be handled here or in a separate issue, but I ran against a problem with facets, ajax and a custom filter key.
On your facet source, you can configure a filter key to update "f" used in the get params to something else. But this parameters is hardcoded in facets-ajax-view.js to "f", which results in broken filters.
Thank you for patch #174!
Was previously using #151, but patch stopped applying while upgrading drupal/facets 2.0.5 => 2.0.6.
Switching to #174 fixed it for me.
- last update
over 1 year ago Patch Failed to Apply - last update
over 1 year ago 420 pass, 3 fail - ๐จ๐ญSwitzerland DonAtt
I was using #174, but with Facets Pretty Paths paging did not work, the Facets filters were lost on page change.
The attached change plus https://www.drupal.org/project/facets_pretty_paths/issues/3129632#commen... ๐ FPP lost path context on ajax request RTBC solved it.
- ๐ท๐ดRomania bogdan.dinu
Hi @DonAtt,
Changing window.location.pathname with url.pathname breaks embedded views. If you have the view and the facets embedded in a page, your code will push in history the url of the view not the url of the current page.
I think you should find a way to manage the parameters needed by Facets Pretty Paths in the url.search variable. - ๐จ๐ญSwitzerland DonAtt
Hi @bogdan.dinu,
Thank you for the feedback, and the great work with this issue!
The trick is that the url.search is the query string (?param=x...) and Facets Pretty Paths is exactly to get rid of the cryptic query parameters and produce nice URLs with the filters in the URL's path part (window.location.pathname).
I guess if this patch (based on #174 then) gets merged, it's worth to look into a Facets Pretty Paths adjustment.
But as in #169 the way forward may rather be the solution based on views exposed filters.
Side-note: as of now 3.0.x with views exposed filters also has problem with paging, the exposed filters block disappear on page change according to my tests.So, then take my approach in #178 only as a quick-fix for now if you don't have embedded views and need to use Facets Pretty Paths.
Hello,
I've a problem with this patch https://www.drupal.org/files/issues/2023-05-14/facets-with-ajax-not-work... โ at this condition:
if (typeof settings.facets !== "undefined" && settings.facets.sliders && settings.facets.sliders[facetId])
when it patches this file js/facets-views-ajax.js
When I debug "settings.facets", I've always "undefined" propertiy
- last update
over 1 year ago 420 pass, 3 fail - last update
over 1 year ago 420 pass, 3 fail - ๐ง๐ชBelgium Tim Lammar
reroll of #174 to be compliant with PHP8.2 (and D10)
- last update
over 1 year ago 420 pass, 3 fail - ๐ง๐ชBelgium p-neyens
reroll of #182 add the missing facets_preprocess_block hook from #174
- last update
over 1 year ago 420 pass, 3 fail - last update
over 1 year ago 420 pass, 3 fail - last update
over 1 year ago 420 pass, 3 fail - last update
over 1 year ago 420 pass, 3 fail - ๐ฌ๐ทGreece balis_m
Patch from #184 works well, except range slider, that throws the following javascript error:
TypeError: unencoded is undefined
I've changed the slider event from "change" to "stop" and it works as expected.
- last update
over 1 year ago 420 pass, 3 fail - ๐ช๐ธSpain akalam
Patch on #185 is working fine unless the site is installed in a subdirectory. I'm adding a new patch covering that use case.
- last update
over 1 year ago 420 pass, 3 fail - ๐ช๐ธSpain akalam
Under some circumstances the facet_link value is an absolute URL so the ajax request fails with a 500 error. Here is a patch fixing it.
- ๐ณ๐ฑNetherlands Ronald van Belzen
None of the patches can be applied to version 2.0.6 by me. Is there a patch that can be applied?
- ๐ณ๐ฟNew Zealand jweowu
The checkboxes become unresponsive after the first time selection.
Someone please correct me if I'm wrong, but AFAIR that was one of the pre-existing problems with the original code. Maybe triple-check that you actually have the patch applied in the code you're running / caches rebuilt / etc...? I would presume that the work here to date does address that issue.
- ๐ฉ๐ฐDenmark Worries
Patch in #183 works for us to AJAXify everything for a facet regardless of where it's placed.
Patches #184 and onward will work with AJAX for list of links or checkboxes, but doesn't work for range sliders specifically, it triggers a page refresh.
- ๐ณ๐ฑNetherlands Ronald van Belzen
Tried patch #187 some more ,but the situation is different from what I first reported.
I have 2 facets filters in my facets block with checkboxes.
When I click one of the filters the checkboxes appear and I can check a checkbox. The filter works, but the checkboxes remain visible.
I cannot hide them any longer and I cannot open the checkboxes of the other filter.
Checking and unchecking the checkboxes of the first filter does result in the correct display of the items in the view, but I cannot close the first filter nor open the second filter anymore.Maybe this is a different issue?
- ๐ฏ๐ดJordan n.ghunaim Amman - Jordan
When I applied the "configure filters" option for the view, the Ajax facets did not work well so it removed what I selected for the exposed filter in the backend. Has anyone faced this before?
- ๐ฉ๐ชGermany mkalkbrenner ๐ฉ๐ช
Thanks to the changes in Drupal 10.1 and the fact that 10.0 will reach EOL in December, there's a lot of progress for AJAX in facets 3.0.x now, based on Drupal 10.1 AJAX in Views.
To be honest, I don't think that anyone of the maintainers will find time to to really fix the AJAX implementation in facets 1.x and 2.x.
I expect that we will release a new facets 3.0.0 beta soon. So I invite everyone to test and improve the new implementation.
- ๐ณ๐ฟNew Zealand jweowu
Is there an upgrade path between 2.x and 3.x, or should we expect that to be a manual process?
- ๐ฉ๐ชGermany mkalkbrenner ๐ฉ๐ช
I don't expect that there will be a fully automated update process that will work for all setups.
We keep the support of the classic blocks setup without AJAX. If you use this, the upgrade path already works. And maybe this will be the only upgrade path, which means manual work after the upgrade if you use AJAX.
AJAX will be View's AJAX. Using exposed filters which could be displayed in different ways, also as blocks.
- ๐ฆ๐บAustralia elgandoz Canberra
I'm starting a new project in D10.1 where I would really like to have facets with AJAX (Facet 3-dev BEF 6).
I followed the steps roughly indicated here https://www.drupal.org/project/facets/issues/3353991 ๐ How to make AJAX work with facets 3? (issue with isRenderedInCurrentRequest) Active but I'm now getting an error:
Error: Object of class Drupal\facets\Entity\Facet could not be converted to string in Drupal\views\Plugin\views\filter\FilterPluginBase->prepareFilterSelectOptions() (line 1344 of core/modules/views/src/Plugin/views/filter/FilterPluginBase.php).
Are those steps corrects? I couldn't find any other guide.
I just would like to know at the current state if it's better to use v2 or v3, considering that AJAX would be great. - ๐ฉ๐ชGermany yannickoo Berlin
I was just experiencing the same as #196 but it seems like you need to change your Facet's widget type to Views exposed filters so it doesn't break.
The next step to adjust your facet source configuration as well so it can read the new URL parameters:
What I have noticed is that there are just simple select lists and no more checkboxes :/
- First commit to issue fork.
- ๐ฆ๐บAustralia elc
This issue seems to be conflating both 2.x and 3.x problems and solutions. For the most part the patches are 2.x, but there are so many of them and there are so many changes that it's near impossible to gather all of the contributions and changes. I know I've missed some so if there is an important change you have previously included in a patch, time to add it to the fork branch.
Both of the existing fork branches are stuck and unable to be rebased onto the existing 2.0.x branch so I've gathered as many of the changes as I could find which are working into a new branch. There are new tests since this issue was opened and they have changed things significantly so I have not worked on getting tests passed other than one or two changes found in patches.
This MR is in a working state for checkboxes in a block at least. I don't have the other types setup. The roadmap of 3.x branch of having blocks without ajax is a loss of an important feature which I can't work with at present, hence needing to get the 2.0.x branch working with the same. Until 3.x has blocks+ajax, it's a step backwards in features and not compatible with existing usage.
The many patches are extraordinarily difficult to work with - let's keep to the MR going forward. I'm sorry I couldn't salvage the other two but they had been merged with 2.x instead of fixed+rebased onto it which tangles them no end. Comparing !26 mergeable and !113 Draft to the latest patches and now this fork, the old MR should be closed off as they are well behind the current state.
Notable change is the adding of the session to the ajax response as I was getting "Session has not been set." for both anon+auth users as I have cookies for all users in use.
Failed to load resource: the server responded with a status of 400 (Bad Request): /facets-block-ajax?_wrapper_format=drupal_ajax:1 Uncaught Drupal.AjaxError: ajax.js?v=10.1.6:1194 StatusText: Bad Request ResponseText: {"message":"Session has not been set."}
NB: Due to pick from #178, the fancy paths do not work on embedded views.
So this 2.0.x-3052574-ajax branch MR is:
- Patch from #187
- Added session to request as detailed above
- url.pathname change from #178
- baseUrl change from MR!113
- Pick test fixes from MR!113
- Fix indenting. Minor CS in edited files only.
- ๐ฎ๐ณIndia shree.yesare
Combined patches from Merge request !162 and Issue: Facets with ajax enabled and no source path results in /views/ajax ๐ Facets with ajax enabled and no source path results in /views/ajax?f... urls RTBC
- ๐ฎ๐นItaly trickfun
Patch doesn't work!!
When i check the first checkbox, all works fine.
When i check the second one i get this error:Uncaught TypeError: Drupal.views.instances[("views_dom_id:" + current_dom_id)] is undefined updateFacetsView https://localhost/modules/contrib/facets/js/facets-views-ajax.js?s90eqh:141 attach https://localhost/modules/contrib/facets/js/facets-views-ajax.js?s90eqh:115 jQuery 7 dispatch handle trigger trigger each each trigger makeCheckbox https://localhost/modules/contrib/facets/js/checkbox-widget.js?v=10.2.3:82 jQuery 8 makeCheckbox https://localhost/modules/contrib/facets/js/checkbox-widget.js?v=10.2.3:76 jQuery 2 makeCheckboxes https://localhost/modules/contrib/facets/js/checkbox-widget.js?v=10.2.3:47 jQuery 2 makeCheckboxes https://localhost/modules/contrib/facets/js/checkbox-widget.js?v=10.2.3:38 attach https://localhost/modules/contrib/facets/js/checkbox-widget.js?v=10.2.3:13 attachBehaviors https://localhost/core/misc/drupal.js?v=10.2.3:166 attachBehaviors https://localhost/core/misc/drupal.js?v=10.2.3:162 insert https://localhost/core/misc/ajax.js?v=10.2.3:1387 jQuery 2 insert https://localhost/core/misc/ajax.js?v=10.2.3:1385 commandExecutionQueue https://localhost/core/misc/ajax.js?v=10.2.3:1046 promise callback*Drupal.Ajax.prototype.commandExecutionQueue/< https://localhost/core/misc/ajax.js?v=10.2.3:1039 commandExecutionQueue https://localhost/core/misc/ajax.js?v=10.2.3:1036 success https://localhost/core/misc/ajax.js?v=10.2.3:1095 success https://localhost/modules/contrib/ajaxin/js/ajaxin.ajax.min.js?v=10.2.3:1 success https://localhost/modules/contrib/blazy/js/base/io/bio.ajax.min.js?s90eqh:1 success https://localhost/core/misc/ajax.js?v=10.2.3:584 jQuery 6 execute https://localhost/core/misc/ajax.js?v=10.2.3:707 updateFacetsBlocks https://localhost/modules/contrib/facets/js/facets-views-ajax.js?s90eqh:230 updateFacetsView https://localhost/modules/contrib/facets/js/facets-views-ajax.js?s90eqh:191 attach https://localhost/modules/contrib/facets/js/facets-views-ajax.js?s90eqh:115 jQuery 7 makeCheckbox https://localhost/modules/contrib/facets/js/checkbox-widget.js?v=10.2.3:82 jQuery 8 makeCheckbox https://localhost/modules/contrib/facets/js/checkbox-widget.js?v=10.2.3:76 jQuery 2 makeCheckboxes https://localhost/modules/contrib/facets/js/checkbox-widget.js?v=10.2.3:47 jQuery 2 makeCheckboxes https://localhost/modules/contrib/facets/js/checkbox-widget.js?v=10.2.3:38 attach https://localhost/modules/contrib/facets/js/checkbox-widget.js?v=10.2.3:13 attachBehaviors https://localhost/core/misc/drupal.js?v=10.2.3:166 attachBehaviors https://localhost/core/misc/drupal.js?v=10.2.3:162 <anonymous> https://localhost/core/misc/drupal.init.js?v=10.2.3:32 listener https://localhost/core/misc/drupal.init.js?v=10.2.3:20 domReady https://localhost/core/misc/drupal.init.js?v=10.2.3:26 <anonymous> https://localhost/core/misc/drupal.init.js?v=10.2.3:31 <anonymous> https://localhost/core/misc/drupal.init.js?v=10.2.3:34 facets-views-ajax.js:141:50
the html is the same after first checkbox
<div class="view view-oto-commerce-catalog view-id-oto_commerce_catalog view-display-id-page_1 js-view-dom-id-3c1385dbbc4d626dc71152fff8473426ea72ab075f92cc908184afd3df177c09" data-once="ajax-pager"> <div class="view-content row">
the current_dom_id variable at line 126 of facets-views-ajax.js file is 3c1385dbbc4d626dc71152fff8473426ea72ab075f92cc908184afd3df177c09 both time.
Drupal.views.instances has not this instance of the views.
Thank you - ๐ฎ๐นItaly trickfun
After remove module and re-apply patch i don't have no more this error but facet option is disabled after selection.
Why?
I can only select the option.
thank you - ๐ฉ๐ชGermany fisherman90 Dortmund
I can confirm, that now MR !162 solves it for me, szenario:
* Page manager page instead of views-page
* Layout builder layout / variant
* Facets and facet-summary renderedBoth - the facets and the summary - are updating correctly for me.
- Status changed to RTBC
10 months ago 2:39pm 17 April 2024 - ๐ฏ๐ดJordan Qusai Taha Amman
MR162 is working fine with me, I created a patch from it.
Thank you! - ๐ฏ๐ดJordan mohammad-fayoumi Amman
#210 ๐ Facets with AJAX not working in most of situations Needs review resolved my issue. Thank you.
- ๐ซ๐ทFrance hesslinger
#210 fine, but i have a one more probleme.
If i have query parametter from exposed filter who start by 'f' letter like 'field_type', Facets range brake url.
exemple ?field_type=587 become ?f[0]=587&f[1]=range:(min:117,max:1000) and brake search...
Replace this code :
if (paramName.substr(0, 1) === 'f') {
byif (paramName.substr(0, 2) === 'f[') {
- ๐บ๐ฆUkraine khiminrm
I have page with two different views blocks - one is the index view as a source for the facets, another one is just simple content views. And I have weird error which not always happened:
Cannot read properties of undefined (reading 'settings')
This is after selecting any second option from the facets.
At this moment (before selecting the 2nd option)
drupalSettings.views.ajaxViews
is empty, butdrupalSettings.facets_views_ajax
is not empty. Maybe there is some time delay in which the drupalSettings.views.ajaxViews is empty. not sure. Can't find source of the bug. Any ideas? - ๐บ๐ธUnited States neclimdul Houston, TX
Notable change is the adding of the session to the ajax response as I was getting "Session has not been set." for both anon+auth users as I have cookies for all users in use.
Failed to load resource: the server responded with a status of 400 (Bad Request): /facets-block-ajax?_wrapper_format=drupal_ajax:1
Uncaught Drupal.AjaxError: ajax.js?v=10.1.6:1194
StatusText: Bad Request
ResponseText: {"message":"Session has not been set."}Adding it to the request not the response but this is a good find. I ran into this testing 10.3 and my ajax facet blocks where suddenly broken. The block in FacetBlockAjaxController that does this solved the problem for us.
- ๐ฎ๐ณIndia ankitv18
Noticed AjaxBehaviorTest phpunit tests are failing while working on the D11 compatibility issue against 2.0.x branch.
I believe tests should also be consider here to update them or provide new once. Also please rebase the MR so that gitlab pipeline would show the actual result. - ๐ฎ๐ณIndia ankitv18
Thanks @vensires apart from these failures https://git.drupalcode.org/issue/facets-3052574/-/jobs/1903753#L873
I've covered all fixes in the Drupal 11 compatibility issue. - Status changed to Needs work
7 months ago 3:52am 20 June 2024 - ๐ฎ๐ณIndia ankitv18
Requires to update the tests especially for AjaxBehaviourTest.php file ~~ hence moving into needs work.
- ๐บ๐ฆUkraine khiminrm
I've noticed that when using range slider the page's URl is updated wrong - it contains the base URL with page path as argument
https://localsite.ddev.site:445/user/3372/selling/closed?https%3A%2F%2Flocalsite.ddev.site%3A445%2Fuser%2F3372%2Fselling%2Fclosed=&f%5B0%5D=total_price%3A(min%3A469%2Cmax%3A21313)
the bug comes from there:var currentHref = window.location.href; var currentQueryParams = Drupal.Views.parseQueryString(currentHref);
so maybe we need to use
var currentQueryParams = Drupal.Views.parseQueryString(href);
And not sure why we need second 'for' loop with replace. On my local site the code works without it. Attaching the patch and diff. - ๐บ๐ฆUkraine khiminrm
Fixed display of prefix and suffix for the slider facet in the facets summary.
- ๐บ๐ฆUkraine khiminrm
I had bugs when used exposed filters like sorting by and number of elements on the page.
I've included fixes from https://www.drupal.org/project/facets/issues/3168241 ๐ Facets and exposed filters don't work together with Ajax RTBC
but replaced also
var href = window.location.href;
with
window.location.search
as I had bug similar as in #219, but when used exposed filter before the checkbox facet.
Also I've included small fix from the https://www.drupal.org/project/facets/issues/3246272#comment-14274178 ๐ Facets AJAX not working with Views pager RTBC - ๐บ๐ธUnited States montag64
I have the exact same error as you on Drupal 10.3 and facets 2.0.7. Which patch worked for you? So far none of the ones I've tried have worked. Did you have to run cron or rebuilt the facets view or do anything else?
- ๐บ๐ธUnited States pbabin
Upgrading to 10.3 had the same issue as neclimdul and montag64 - I used the 3052574-212.patch to get this resolved.
- ๐ฎ๐ณIndia prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan
After applying patch #221, clicking on any exposed filter facet removes unrelated facet items from the facets block. However, when the facet is unticked, the items do not reappear.
- ๐ต๐ฑPoland marcjana_84
Same problem.
Drupal 10.3.0, Facets 2.0.7, Ajax works only for the first click, and then you cant't change filtering options.
In logs "Symfony\Component\HttpKernel\Exception\BadRequestHttpException: Session has not been set. in Symfony\Component\HttpKernel\HttpKernel->handle() (line 83 in /var/www/html/vendor/symfony/http-kernel/HttpKernel.php)." - ๐จ๐ณChina hongqing
Same issue after upgrading from 10.2.6 to 10.3.0, 3052574-212.patch resolve it.
- ๐บ๐ธUnited States montag64
@pbabin I tried that patch as well and it didn't fix the issue for me. Did you have to rebuild the facet or do anything else beyond apply the patch? We did a drush cr
- ๐บ๐ธUnited States pbabin
@montag64 - I ended up having to remove another one of our patches for facets. Standard Drush cr after the build nothing else
Before 10.3 these were the patches we used
"Facets and exposed filters don't work together with Ajax": "https://www.drupal.org/files/issues/2021-12-05/3168241-8.patch", "Ajax facet block seems to lose Views context": "https://www.drupal.org/files/issues/2023-01-04/2986981-32.patch", "Config imports of facets leads to fatal errors": "https://git.drupalcode.org/project/facets/-/merge_requests/199.patch"
after 10.3
"Ajax issues": "https://www.drupal.org/files/issues/2024-05-07/3052574-212.patch", "Config imports of facets leads to fatal errors": "https://git.drupalcode.org/project/facets/-/merge_requests/199.patch"
- ๐ต๐ฑPoland marcjana_84
In my case 3052574-212.patch also did't solve the problem.
- ๐ฎ๐นItaly trickfun
None of the patches above work properly.
With today's dev version you can't install them.Without patch module doesn't work.
When i select a checkbox all facets disappear.what happens?
- ๐ฎ๐ณIndia prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan
Yes i Have Tried Many patches From This issue not any patch fix the issue of the all facets disappear.
- ๐ฎ๐นItaly trickfun
So.
Facets 2.0 with Drupal ^10.2 works fine. No patch applied, No strange behavior
Facets 2.0 with Drupal 10.3 doesn't work. Facets disappeared after click option.When i refresh page I have this HTML element
<div class="facet-inactive block-facets-ajax js-facet-block-id-carsproductbrand block-facet--checkbox" id="block-carsproductbrand">
with all checkboxes. fine!!
after click one option i get correct json responseObject { command: "insert", method: "replaceWith", selector: "#block-carsproductbrand", โฆ }
Html element is replaced by
<div class="facet-inactive block-facets-ajax js-facet-block-id-carsproductbrand hidden block-facet--checkbox" id="block-carsproductbrand--7fYNYNMIFpk"> <div data-drupal-facet-id="cars_product_brand" class="facet-empty facet-hidden"> <div class="facets-widget-checkbox"> </div> </div> </div>
Facets-widget-checkbox is empty.
Why first time facets-widget-checkbox element has options and new facets none?Facets 2.0 on Drupal 10.3 with patch #221 - 3052574-221.patch works fine.
Hope can help someone. - ๐ซ๐ฎFinland simohell
Patch from #221 fixes the functionality for me. I am however getting
Uncaught TypeError: Cannot set properties of undefined (setting 'closeMessage') at messages.js?v=10.3.1:54:27 at messages.js?v=10.3.1:55:3
on each click, but so far I don't see it causing any problems.
- ๐ซ๐ฎFinland simohell
On some occasions on 10.3 logged in as admin with #221 also gives me
VM890 facets-views-ajax.js:202 Uncaught TypeError: Cannot read properties of undefined (reading 'facets_summary_ajax_summary') at updateFacetsSummaryBlock (VM890 facets-views-ajax.js:202:36) at updateFacetsBlocks (VM890 facets-views-ajax.js:179:9) at updateFacetsView (VM890 facets-views-ajax.js:154:5) at HTMLUListElement.<anonymous> (VM890 facets-views-ajax.js:89:17) at HTMLUListElement.dispatch (VM835 jquery.min.js:2:40035) at v.handle (VM835 jquery.min.js:2:38006) at Object.trigger (VM835 jquery.min.js:2:70124) at HTMLUListElement.<anonymous> (VM835 jquery.min.js:2:70726) at Function.each (VM835 jquery.min.js:2:3129) at ce.fn.init.each (VM835 jquery.min.js:2:1594)
And after that stops accepting checking facets from the same group (I have several taxonomies with their own sets).
It seems to work for anonymous, however. - Status changed to Needs review
7 months ago 12:59pm 8 July 2024 - ๐จ๐พCyprus alex.bukach
Patch #221 seems to work fine for me, however I face the issue mentioned in #236 too. Here's an updated patch.
- ๐บ๐ธUnited States pbabin
I re-applied a few other patches and then added #237 from above. The session has not been set error that was previous being displayed is now removed. In our setup, I'm not seeing an issue.
- ๐ต๐นPortugal joao.ramos.costa
Hi @Alex Bukach,
thank you for the patch.
I've applied it, but unfortunatelly on my end (PHP 8.3, D10.3.1, Facets 2.0.7) it ended up duplicating the existing libraries and broking some facet widget behaviors.
It seemed solved in my case by adding request parameters to the new request parameters , allowing Drupal\Core\Ajax\AjaxResponseAttachmentsProcessor::buildAttachmentsCommands() filtering out existing libraries from ajax_page_state key:
https://git.drupalcode.org/project/drupal/-/blob/11.x/core/lib/Drupal/Co....ie:
if ($request->hasSession()) { $request->getSession()->save(); $new_request->setSession($request->getSession()); $parameters = $request->request->all(); $new_request->request->replace($parameters); }
But it seems to fix this momentarily, I'm not sure of the impact of it.
But looking back now, seems to related with:
https://www.drupal.org/project/facets/issues/3211155 โ .Thanks
- ๐บ๐ธUnited States jennypanighetti
I just upgraded to the Drupal 10.3.x branch and unfortunately, patch from #237 did not work for me (neither did 221 nor the suggestions in 229). There's no errors in the dblog or the console, and technically the facets function but they are no longer Ajaxed - I'm getting
blog?f[0]=category%3A5081
in my URL, and they are pushing to the history.Not sure if that should be for this issue or a new issue...
- ๐ฉ๐ชGermany svenseeberg
I commented 2 lines in the
src/Controller/FacetBlockAjaxController.php
and now I do at least not get an error message:<?php foreach ($facets_blocks as $block_id => $block_selector) { $block_entity = $this->storage->load($block_id); if ($block_entity) { // Render a block, then add it to the response as a replace command. $block_view = $this->entityTypeManager ->getViewBuilder('block') ->view($block_entity); //$block_view = (string) $this->renderer->renderPlain($block_view); //$response->addCommand(new ReplaceCommand($block_selector, $block_view)); } } ?>
The request to /de/facets-block-ajax?_wrapper_format=drupal_ajax then returns a valid looking response with 200 OK. However, I'm not sure if the GUI is working as intended.
- ๐ต๐นPortugal joao.ramos.costa
Hi @svenseeberg,
Thanks for following up on my incomplete information.
To whom it may concern, I'm actually using the patch from #138, with a local patch on top of it adding the request session. As after @idebr very useful patch there was already a trajectory on the issue and I haven't had time to specifically analyze its impact, although it works on my project, I haven't yet added a patch here. I'll do that soon.Cheers!
- ๐บ๐ฆUkraine vlad.dancer Kyiv
I came here from ๐ [1.15.0] bug, "Session has not been set" error thrown by select2_facets Needs review where ajax doesn't work after updating drupal core to 10.3+. While worked on solution I found code places in facets module where
Request::create
beeing used too:facets/src/Controller/FacetBlockAjaxController.php
. So there is high chance that ajax facets won't wotrk too on drupal 10.3+. Probably because of changes in core/modules/views/src/ViewExecutable.php
It looks like @joao.ramos.costa and @svenseeberg have already expirienced this bug and can confirm it. Adding session is requred now (when dealing with views?):$new_request = Request::create($path); $new_request->setSession($request->getSession());
- ๐ฌ๐งUnited Kingdom 3li U.K. ๐ฌ๐ง
Following on from #243 about Session not set warning.
I have added a patch that seems to remove the warning for myself.I do have a feeling this should be added to another issue though.
- ๐ฎ๐ณIndia prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan
I have applied the Patch one by one #237 and #244, and ajax is working fine but . However, I have placed the facet blocks on the view page with the exposed filter, and on submitting the exposed filter, the facet values are not updating according to the filter values. I tested this on version 10.3.
- ๐บ๐ธUnited States alison
We also started having trouble when we updated to core 10.3 (10.3.1, to be precise, but we skipped 10.3.0).
We have a view page with an exposed form, plus the facet block. As has been described, when you go to the view page, you can select a facet checkbox -- everything works fine -- but then you can't uncheck that box, or select another box in the same facet (this view has two facets in use on it -- you can check a box in the other facet, but then, same thing for that facet: you can't deselect that box, or select another box in that facet).
#244 completely fixes the issue for us. Full disclosure: I did not try the other recent patches. (We're on Facets 2.0.7.)
- ๐จ๐ฆCanada drclaw
Regarding the issue with the session not being set on Drupal 10.3+, there is another issue with a patch for that:
๐ Creating requests causes failures on Drupal 10.3 Active
- ๐บ๐ธUnited States alison
Hmmm so, is that one (3466281) a duplicate, or are they separate issues? (or are they separate issues and we've scope-creeped on this thread (3052574)?)
- ๐บ๐ธUnited States pbabin
I'd argue for scope creep potentially. We're on Drupal 10.3.2 and using Facets 2.0.8 with search api and none of the previous patches are working. I was using patch 237 to address the session is not set issue but with 2.0.8 I wasn't able to apply this patch anymore. The patches in 3466281 don't appear to be the way to go as it is using a mock and I was told that this is usually only for testing and shouldn't be applied to code. I'd greatly appreciate some feedback on how to proceed with my current setup as my patch for 2.0.8 does not appear to be applicable.
- ๐ณ๐ฑNetherlands spokje
Reroll of #244 ๐ Facets with AJAX not working in most of situations Needs review for 2.0.8.
- ๐บ๐ธUnited States pbabin
@Spokje - Dank je wel! 251 reroll of 244 is working on our end.
Applied 251 in 2.0.8 and we are not getting the session is not set error.
- ๐ฆ๐บAustralia elc
Re-roll of #3052574-237: Facets with AJAX not working in most of situations โ for 2.0.8.
Also had to patch in:
- #3466566-3: New $request created in FacetBlockAjaxController missing ajax_page_state โ
- #2986981-42: Ajax facet block seems to lose Views context (filters, etc) โ
Due to the close quarters of code changes, these do not cleanly apply. Appended a custom patch for #3466566-3: New $request created in FacetBlockAjaxController missing ajax_page_state โ to apply after this one.
No need to also apply #251 as it is handled by this patch.
- ๐ต๐นPortugal joao.ramos.costa
Thank you @elc,
your patch and #254 suggestions worked for my case (D10.3.1 , Facets 2.0.8, Search API 1.35.0).
- ๐ฎ๐ณIndia Hemangi Gokhale
Hello,
The patch from #254 โ almost resolved the issue.
Whenever I select a second independent facet element, I get:
Uncaught TypeError: settings.facets_views_ajax is undefined
- ๐ฌ๐งUnited Kingdom John Cook
I used the patch in #215 and that worked for me.
```
Drupal: 10.3.1
Search API: 8.x-1.35
Facets: 2.0.8
``` - ๐บ๐ธUnited States michalsen
Drupal 10.3.6
Search API: 8.x-1.35
Facets 2.0.9The recent update to 2.0.9 caused a composer build error with #254 ๐ Facets with AJAX not working in most of situations Needs review . Patch #251 ๐ Facets with AJAX not working in most of situations Needs review worked
- ๐ฌ๐งUnited Kingdom c_archer Cumbria
Patch in #220 no longer applies against facet version 2.0.9
- ๐บ๐ธUnited States imran1217
Re-roll of patch in #254 against facets version 2.0.9
- ๐ณ๐ฑNetherlands Lendude Amsterdam
#263 breaks for us when a block ID is found but a Broken block is loaded in
$block_instance = $this->blockManager->createInstance($block_id);
, so added hardening against that - ๐ช๐ธSpain pcambra Asturies
#251 is still the canonical patch for this issue, the rest include other patches.
- ๐ซ๐ทFrance hesslinger
#265 work, but not keep #212 fix.
Probleme :
If i have query parametter from exposed filter who start by 'f' letter like 'field_type', Facets range brake url.exemple ?field_type=587 become ?f[0]=587&f[1]=range:(min:117,max:1000) and brake search...
Replace this code :
if (paramName.substr(0, 1) === 'f') {
by
if (paramName.substr(0, 2) === 'f[') {
Fix it.. - ๐ง๐พBelarus VasiliyRepin Minsk
#270 doesn't work with facets_block module. I need this module very much, because project have teens facet blocks.
- ๐บ๐ธUnited States karlshea Minneapolis ๐บ๐ธ
Rebased !162 on 2.0.x. It doesn't apply cleanly to 2.0.9 right now because there's been a change to facets-views-ajax.js since that was tagged, but that's the only change right now.
- ๐บ๐ธUnited States karlshea Minneapolis ๐บ๐ธ
I also need a separate patch on top for the facets range summary to work, I'm not sure if that should go into the MR or not?
This is the patch for DefaultFacetsSummaryManager:
// @todo Keep non-facet related get params. - $url = Url::fromUserInput($facets_summary->getFacetSource()->getPath()); + $path = \Drupal::service('path.current')->getPath(); + /** @var \Drupal\path_alias\AliasManager $pathAliasManager */ + $pathAliasManager = \Drupal::service('path_alias.manager'); + $path = $pathAliasManager->getAliasByPath($path); + try { + $url = Url::fromUserInput($path); + } + catch (InvalidArgumentException $e) { + $url = Url::fromUri($path); + }
- ๐ง๐ชBelgium BramDriesen Belgium ๐ง๐ช
MR !162 actually does apply cleanly for me on the latest tagged release.
Uploading a static patch.
- ๐ฎ๐ฑIsrael jsacksick
I've been testing the patch on Commerce Kickstart and Drupal 11 and was encountering issues... After filtering, I all the checkboxes remain disabled and couldn't "uncheck" facets anymore, the whoe facet block was "disabled".
- Status changed to RTBC
2 months ago 3:29pm 19 November 2024 - ๐บ๐ธUnited States John Franklin
@jsacksick - can you add a unit test that demonstrates the facets issues you're experiencing?
- ๐บ๐ธUnited States John Franklin
@jsacksick - can you add a unit test that demonstrates the facets issues you're experiencing?
- ๐ฆ๐บAustralia Toby Wild
Apologies John, I don't know how to write unit tests, however I can also confirm the same behaviour.
Using the patch from #275, when a facet is activated, the search occurs, all other facet elements in the same facet group are given a 'disabled=disabled' attribute.
If there are other facets on the page, they are still active and working, however only until you use a single facet in each group.
Manually removing the disabled=disabled attribute makes the inputs interact-able, but doesn't actually trigger a search.
An error message is reported in the console:
Session has not been set.
Wow, feels great to run up against an issue and see it being resolved in real time.
Patch #270 solves the issue for me as well on version 2.0.9, thanks.- ๐จ๐ณChina skyredwang Shanghai
I tested both #270 and #275, neither works for me; still getting this error:
Uncaught TypeError: Cannot read properties of undefined (reading 'facets_summary_ajax_summary')
Because, 2.0.9 was a security release, and sites cannot roll back to a previous working version. I am bumping the priority of this issue up.
- ๐ฎ๐นItaly trickfun
Patch #270 works for me with version 2.0.9.
Thank you - ๐ฌ๐ทGreece vensires
As a sum up, I think that what we should keep from the comments above is that patch #270 works and fixes all the issues BUT the one described in #283 where a facets summary exists in the page. Might it be that the solution identified in #274 is what we need?
- ๐ฎ๐นItaly trickfun
In another project i have this error
module 2.0.9 and patch #270Uncaught TypeError: Drupal.facets is undefined attach https://tc.algra.it/modules/contrib/facets/js/soft-limit.js?v=10.3.10:14
soft-limit.js hasn't Drupal in (function ($, once) {
row 6 and row 73and
TypeError: settings.facets_views_ajax is undefined updateFacetsSummaryBlock https://tc.algra.it/modules/contrib/facets/js/facets-views-ajax.js?som2ct:227
inside updateFacetsSummaryBlock function i don't have settings.facets_views_ajax variable
i don't install summary block.I update patch #270 with both fix
- First commit to issue fork.
- ๐ณ๐ฑNetherlands rbosscher
#285 has resolved all the issues I encountered, including the facets_summary_ajax_summary error. Thank you all for the effort put into this patchโit works perfectly for my use case!
Can anybody confirm this fix, so we can proceed with creating a merge request?
- Status changed to Needs review
9 days ago 6:35am 20 January 2025 - ๐ฎ๐ณIndia joshua1234511 Goa
The tests modified in the MR (https://git.drupalcode.org/project/facets/-/merge_requests/162/diffs?commit_id=40abf8f878d10c3b1c10cbf1029aaf4d42313ffb) are no longer required, as the Ajax behavior they validate has been removed from the main branch. This can be verified by referring to the comparison here: https://git.drupalcode.org/project/facets/-/compare/995bd75a428b8bfc85236d0100436735277814a1...5993b7a2b36412bdb4e1daa838e445cb7c93f20e .
Can proceed with testing and mark the MR as ready to merge.