Home > widget-integration > RecommendationWidgetController > handleClickOutsideBundleDropdown

RecommendationWidgetController.handleClickOutsideBundleDropdown() method

Handles click events outside bundle dropdowns to close them.

Implements click-outside behavior for dropdown menus to provide intuitive UX. When a click occurs outside the dropdown or its trigger, the dropdown closes. Override this method to customize close behavior or add additional event handling.

Signature:

handleClickOutsideBundleDropdown(e: MouseEvent): void;

Parameters

Parameter

Type

Description

e

MouseEvent

The mouse event from the document click listener containing target information

Returns:

void

Remarks

This method is automatically bound to document click events when the controller is instantiated. It manages both single and multiple dropdown states.

Example

Override to add analytics tracking:

public handleClickOutsideBundleDropdown(e: MouseEvent): void {
  const hadOpenDropdown = this.openingBundleDropdownIdx.value >= 0;

  super.handleClickOutsideBundleDropdown(e);

  if (hadOpenDropdown && this.openingBundleDropdownIdx.value < 0) {
    this.analytics.track('dropdown_closed_outside_click', {
      widgetId: this.props?.value.widgetId
    });
  }
}