I can't get ajax facets to work properly. I have a search api view with a page display and an exposed search text field and two facet blocks.

While the ajax facets work great on their own, they disregard the exposed views filter. For example if I enter a search term the view is refreshed correctly. But the facets aren't updated accordingly. I see there's a call to facets-block-ajax, but it returns the same results as if the search field wasn't used.

All this works properly when ajax is disabled.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Ice-D created an issue. See original summary.

Ice-D’s picture

FileSize
1 KB

I 've written a patch that works for me.

Ice-D’s picture

Status: Active » Needs review
Ice-D’s picture

FileSize
1.06 KB

Small correction.

The last submitted patch, 2: 2986020-2.patch, failed testing. View results

Ice-D’s picture

FileSize
1.09 KB

Another fix. Still not sure if the issue is only on my end though.

TuWebO’s picture

Hello,
I will double check, but have similar problem (I think).

TuWebO’s picture

Hello,
I confirm, same issue as described here and patch #6 is working fine for me.
Just did a quick test, but It is working with hierarchycal facets and normal ones.

Thanks very much @Ice-D, I will try to also test a little bit more.

Ice-D’s picture

FileSize
1.03 KB

Thanks for checking the patch @TuWebO!

Here I'm just making the code a little shorter and more readable.

Ice-D’s picture

FileSize
1000 bytes

Even shorter.

Ice-D’s picture

FileSize
967 bytes

Removed unused variable.

Status: Needs review » Needs work

The last submitted patch, 11: 2986020-11.patch, failed testing. View results

Ice-D’s picture

Status: Needs work » Needs review
ma_ko’s picture

Latest patch is working for us, too.

borisson_’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

That looks great, we should probably add tests as well for this.

Ice-D’s picture

Assigned: Unassigned » Ice-D

I've never written a test but I'll give it a try.

borisson_’s picture

If you can't figure it out, that would be understandable, because we're should write a JavascriptTestBase test for this. Those are really hard to write. I should have some time over the weekend to look at this.

Ice-D’s picture

Assigned: Ice-D » Unassigned

Alright, unassigning for now because I don't have much time ;) I'll check your test and learn from it :)

borisson_’s picture

Status: Needs work » Needs review
FileSize
2.6 KB
3.55 KB
Ice-D’s picture

Status: Needs review » Reviewed & tested by the community

Works good for me!

TuWebO’s picture

Hello,
Testing it again and soft limits seems not to be applied. I've red this issue #2985159: AJAX update breaks soft-limits which seems to be related to this one for the once() part.
Is it something that we should work on this issue or we should add another issue for this?
Thanks again, ajax is working really good.

  • borisson_ committed e3d5d3e on 8.x-1.x
    Issue #2986020 by Ice-D, borisson_: Ajax facets don't respect views...
borisson_’s picture

Status: Reviewed & tested by the community » Fixed

Soft limits is another issue, can you open a new issue in the queue here? That would be awesome! Thanks.

TuWebO’s picture

Hi @borisson_ ok, I'll test them in clean installation and post an issue if I find something weird. I have to double check that wrong behaviour wasn't because of my code.
Thanks to everybody, this is a really nice feature, and works pretty well.

borisson_’s picture

@TuWebO: I checked the commit history yesterday evening, and noticed that there was a commit to fix soft limits with ajax already. I'm trying to get a new release out this week.

TuWebO’s picture

Hi @borisson_ great news then. We will wait then and test it in the new release.

andyg5000’s picture

Thank y'all for this!

On a related note, I was stumped by facets showing up that were unrelated to the filtered views results. It was because the default option for new facets is "OR" instead of "AND". Simple fix, but I ended up all the way here before I figured it out. Dropping a note for others that get caught by the same config issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.