Filtering tags as well as articles

Hi guys, in attempt to stop my brain boiling over, I wondered if you have already experienced this requirement. I use a general tags across three different article types (demo example URL provided). I use nested + filters.

As you will see from the example, users can first narrow a search by article type. Then select the tags to refine by subject matter/tag. Is there any way to only show tags from the secondary filter that have articles of that type when selected? For example, there are tags that are NOT applied to many FAQs and Videos, so by showing all tags, the user is potentially frustrated by a series of tag selections that return no results.

Put very simply, I only want to show tags that have results.

Working model with a small selection of data
https://uc-knowledgebase-framework.webflow.io/

*wireframe MVP, so please don’t judge the design :wink:

Hey @ian! Can you please test this code? you can paste it into the </body> section of the page :wink:

Here it is working

<script>
  window.fsAttributes = window.fsAttributes || [];
  window.fsAttributes.push([
    'cmsfilter',
    (filterInstances) => {
      console.log('cmsfilter Successfully loaded!');

      // The callback passes a `filterInstances` array with all the `CMSFilters` instances on the page.
      const [filterInstance] = filterInstances;
      const filterFields = filterInstance.filtersData;

      // The `renderitems` event runs whenever the list renders items after filtering.
      filterInstance.listInstance.on('renderitems', (renderedItems) => {
        filterFields.forEach((filterField) => {
          const elements = filterField.elements;

          elements.forEach((element) => {
            element.element.parentElement.style.display =
              element.resultsCount === 0 ? 'none' : 'flex';
          });
        });
      });
    },
  ]);
</script>