Hide Section w/ Empty Collection Lists ❺
Hide an entire section when the collection lists in it are empty
Last updated
Hide an entire section when the collection lists in it are empty
Last updated
Suppose you have an area of your page called “alerts” and it has some nice styling and icons… but sometimes, there are no alerts to show. How do you make the whole thing disappear when there are no alerts in the Collection List for display?
This solution provides two simple attributes-based methods to do just that.
We have two slightly different solutions here, depending on your needs. In both solutions, if ALL of the collection lists within the attribute-tagged section are empty, the entire section will be hidden.
Click the toggle next to the solution you want.
If you want a solution that works with all browsers, use the suppress feature.
If you need a solution that is dynamic, and can respond to changes after the page has loaded - such as those made by Finsweet's CMS Filter - use this solution. However the CSS technique used here is not supported by Firefox.
To recap;
Hide mode is CSS-based and will not work with Firefox- however it is dynamic and will work with Finsweet's CMS filter.
Suppress mode is JS-based and will work with all browsers- however it executes at page load time, and will not respond to dynamic list changes after the page has loaded.
Hide mode is 100% CSS-based, and leverages the :has()
pseudoselector. However this CSS feature is not yet supported by all browsers, most notably Firefox. If you need 100% browser coverage, you should use our Suppress mode until Firefox implements :has fully.
As of Aug-2023, Firefox has about 7% desktop share, but almost 0% mobile. If your site primarily targets mobile users, Firefox's lack of support for CSS :has will not affect you.
First, add the library as detailed in Quick Start.
wfu-hide
or wfu-suppress
to the sections you want to hideSee above for details.