Custom Module / Categories Filter Bug

I have a simple Custom Module List.

     {% for item in this.items %} 
     {% endfor %}

Using the system categories to filter the data on a page using either Filter or Search scope as show below.

{% component source: "Fitness", layout: "List", searchScope: "{'prop_ItemCategories':'Classes'}", object: "collection", type: "module" %}
{% component source: "Fitness", layout: "List", filterBy: "ItemCategories", filterValue: "Classes", object: "collection", type: "module" %}

The List Always displays the section and the title of the list. Even when there are no items in the category or even when there are no items in the custom module at all. Filtering and search scope work with any other field just fine. This site currently only has a few categories so I just created a drop down in the module to make this work.

@Rhatch Is the bug that <section> and <h1>Title</h1> are always displayed, even when there are no items in the category your are filtering for?

I believe that’s behaving as intended, unless I’m misunderstanding.

When you render a module as object: “collection”, everything in the layout will be displayed an only the content in your for loop will be looped.

Is your desire to not have the section and h1 elements display if there are no items?

@Alex_B_Centrifuge, from my tests and workings with this. If my layout is in the custom module “List” nothing displays unless there is an item or one that meets the filter requirements. If there is no item id doesn’t call the list at all.
If my layout is in the content template or on the actual page then yes, what is outside my for loop is displayed and what’s in my for loop is the module content. I have my layout in the custom module list layout. This doesn’t display anything except for when I filter or scope search is set to categories. Then what’s outside the for loop displays regardless ? Any other filter work, as I think is should, or have experienced by not displaying anything unless there is an item that meets the search or filter results.

I have used this on a few sites for things like current specials, content that isn’t always there so I don’t need a blank header or other content.

So I don’t know if this is a bug or what. I seem to always find issues with Categories.

@Rhatch just to be clear, the expected behaviour is:
when inserting a module as a collection and using a for loop in the module layout, and the filter limits the output to no items, you expect to see none of the module layout? (Not even the part outside the for loop)

And the bug you are seeing is that the part of the module layout that is outside of the for loop is being displayed even when there are no items?

Is that correct?

Hi @Rhatch
I can’t replicate this in my tests. The layout never renders anything if there are no items returned, whether I filter by category or any other field.
There might be something else coming into effect here??? or perhaps it’s a bug just on your site instance?

I’d also try reindexing the site as it may be an indexing issue.