Skip to main content

Widget closed

This event is triggered when a widget is closed, indicating that the widget is no longer active on the page.

Event details​

When the widgetClosed event occurs, the received event.detail object includes the following properties:

WidgetClosedSdkEvent
event
Properties
readonly typeWIDGET_CLOSED
Event type, always "widgetClosed"
readonly widgetNamestring
Name of the widget that was closed

Usage example​

Ensure the SDK is ready before setting up the widgetClosed listener:

function onSdkReady() {
const eventName = window.gw.sdk.common.events.WIDGET_CLOSED;

window.gw.sdk.on(eventName, (event) => {
console.log(event.detail);
});
}

if (window.gw && window.gw.sdk) {
onSdkReady();
} else {
document.addEventListener("gwSdkReady", onSdkReady);
}

// Example output:
// {type: 'widgetClosed', widgetName: 'ReviewsFormModalWidget'}

This code ensures that the SDK is ready before listening for the event, allowing you to respond when a widget is closed and take appropriate action.

Possible widgetName values​

  • ReviewsFormModalWidget
  • ReviewsDrawerWidget
  • RewardsPopUpWidget
  • WishlistDrawerWidget