Home > widget-integration > FilterController > setupDocumentClickEvent

FilterController.setupDocumentClickEvent() method

Sets up click event listeners on the filter document context. Delegates all click handling within the filter scope to the FilterHandler.

This method uses event delegation to efficiently handle all clicks within the filter context, including filter options, buttons, links, and interactive elements.

Signature:

setupDocumentClickEvent(): Promise<void>;

Returns:

Promise<void>

Remarks

The actual click handling logic is delegated to FilterHandler.handleCoreClick(), which processes different click targets and triggers appropriate actions. This separation of concerns keeps the controller focused on setup while the handler manages the event processing logic.

Example

Override to add pre-processing before core click handling:

window.boostWidgetIntegration.extend('FilterController', (FilterController) => {
  return class CustomFilterController extends FilterController {
    async setupDocumentClickEvent() {
      const contextDocument = this.filterStore.state.value.document;
      contextDocument?.addEventListener('click', (event) => {
        // Add custom analytics tracking
        this.trackFilterClick(event.target);

        // Call original handler
        this.filterHandler.handleCoreClick(event);
      });
    }
  };
});