Hey @joseph.bongrand! The issue seems to come from the event listeners attached to the document — I’m afraid we don’t dispatch the events you’re listening to, so the function to hide the empty months isn’t being triggered.
Instead, we can listen to the renderitems
event. This is fired every time items are rendered on the page — whether filters are set or removed:
// All previous code stays the same, just add this instead of the event listeners
// === Watch Finsweet lifecycle events
const [filterInstance] = filterInstances;
filterInstance.listInstance.on('renderitems', (renderedItems) => {
setTimeout(updateMonthGroupVisibility, 50);
});
If you’d like an alternative approach, you can try reverse nesting the events within the corresponding months, as shown in this guide: