Skip to content

changed

changed is a DOM event that occurs whenever the state of the h-tabs webcomponent changes..

Event body

The changed body has a TTabsChangedEventDetail type which represents the details of the changed tab. It is optional so it might not exist.

Example

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

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

        if (!detail) return;

        const { $previousTab, $newTab } = detail;

        console.log($previousTab, ' has been deselected and ', $newTab, ' has been selected');
    });
});