Skip to content

flashMessageClose

flashMessageClose is a DOM event that occurs whenever the flash-message webcomponent is closed.

Event body

The flashMessageClose body has a TFlashMessageCloseEvent type which represents the details of the closed flash message. It is optional so it might not exist.

Example

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

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

        console.log('flash-message has been closed with id:', id);
    });
});