- Issue created by @SirClickALot
- ๐ฎ๐ณIndia Jeya sundhar Coimbatore
Jeya sundhar โ made their first commit to this issueโs fork.
- Merge request !200Issue #3264284 by BAHbKA, mkalkbrenner: Facets summary should be cacheable, in... โ (Closed) created by Jeya sundhar
- Status changed to Needs review
7 months ago 5:42am 17 April 2024 - ๐บ๐ธUnited States devkinetic
I haven't dug into this too much, is the container there for some type of ajax purpose? I also see this is already handled differently in 3.x where it returns an empty array, perhaps that would be the preferrable solution. I went ahead and applied the patch, so far in testing things are working, but I do have Bigpipe disabled for facets, if that's a potential factor.
- ๐ง๐ชBelgium ludo.r Brussels
Just tested patch #6, it indeed returns an empty block.
However, I removed the patch, as I see that the default behavior of facets module is to show the block but add the
hidden
class.
So I think there must be a reason for that.In the end it's just our theme that overrides the
hidden
class, we'll fix it with css and respect whenhidden
is being added.See https://git.drupalcode.org/project/facets/-/blob/3.0.x/facets.module?ref...
- ๐บ๐ธUnited States mlncn Minneapolis, MN, USA
OK, fascinating that the
hidden
class is added rather than the block suppressed. Would like to know why. That approach makes it a lot harder to avoid outputting surrounding markup when there are no facets at all.Also, Facets is responsible for adding CSS for classes it relies on; while a common class, hidden cannot be expected on every theme.
- ๐ง๐ชBelgium ludo.r Brussels
My guess (and I bet), that there's a good reason for that.
Imagine a seach page (99% a views page), where you come with a specific parameter in the URL for Facet A.
Facet B has no result with param for Facet A.If you have an ajax view and uncheck param in Facet A, you might need to show results in Facet B.
That's a good reason to use thehidden
class rather than not showing the block at all.Btw, IMHO, I think the
hidden
class can be used by anyone (theme, contrib module), it's feature of Drupal. - ๐บ๐ธUnited States mlncn Minneapolis, MN, USA
Yeah. And i figured out some whacky CSS to hide the facets section if no facets are visible!
.facets-views-plugin:has(.block-facet--links) { display: none; } .facets-views-plugin:not(:has(.hidden)) { display: flex; }
That was our use case, probably
display: block
will be more common than flex. And the first:has()
is not "needed" but it avoids hiding the facets permanently for the dwindling number of browsers (under 8% share) that do not support has.Putting this here for anyone else who wants to use it, not for inclusion in Facets.