Skip to content

updateFilter

updateFilter is a DOM event that occurs whenever the filter value is updated.

Event body

The updateFilter body has a TFilterConstructorOptions type which represents the details of the updated filter. It is optional so it might not exist.

Example

In this example we listen to updateFilter event and perform an action whenever it's emitted.

useStorefront(async (storefront) => {
    document.addEventListener('updateFilter', (event) => {
        const filterDetails = event.detail;

        const { id, name } = filterDetails

        console.log('Updated filter:', id, name);
    });
});