Skip to content

deselect

deselect is a DOM event that occurs whenever the variant option is deselected.

Event body

The deselect body has a VariantStockOptionValue or VariantVirtualOptionValue type depending on an option type which represents the details of the deselected option. It is optional so it might not exist.

Example

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

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

        console.log('deselected option:', option);
    });
});
```