Skip to content

deselect

deselect is a DOM event that occurs whenever the option on the h-select webcomponent gets deselected.

Event body

The deselect body has a string type which represents the value of a previously selected 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 selectValue = event.detail;

        console.log('Select had a previous value of', selectValue, 'but got deselected');
    });
});