removeHistoryItem¶
removeHistoryItem
is a DOM event that occurs whenever the item inside the h-storefront-search webcomponent is being removed from the history.
Event body¶
The removeHistoryItem
body has a RemoveHistoryItemEvent type which represents the details of the removed item from the history. It is optional so it might not exist.
Example¶
In this example we listen to removeHistoryItem
event and perform an action whenever it's emitted.
useStorefront(async (storefront) => {
document.addEventListener('removeHistoryItem', (event) => {
const detail = event.detail;
if (!detail) return;
const { id, moduleInstanceId } = detail;
console.log('Element of id ', id, ' has been removed from history of search with id ', moduleInstanceId);
});
});