Skip to content

close

close is a DOM event that occurs whenever the h-portal webcomponent is being closed.

Event body

The close body has a TPortalEventData type which represents the details of the opened portal. It is optional so it might not exist.

Example

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

useStorefront(async (storefront) => {
    document.addEventListener('close', () => {
        console.log('A portal has been closed');
    });
});