Home > widget-integration > FilterHandler > handleAction
FilterHandler.handleAction() method
Routes individual action types to their corresponding event handlers.
Central action dispatcher that emits appropriate EVENT_NAMES events based on the action type. This is called by handleMetadataActions and handleActionMapping to process both legacy metadata actions and action mapping system actions. Override this method to intercept specific action types or add custom action handling logic.
Signature:
handleAction(key: string, action: any, target: HTMLElement): void;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
key |
string |
The action type string (e.g., 'optionList', 'clearAllFilter') |
|
action |
any |
The action configuration object containing action data |
|
target |
HTMLElement |
The DOM element that triggered the action |
Returns:
void
Remarks
Each action type emits a corresponding EVENT_NAMES event with the action configuration and target element. Unknown action types are logged as warnings to help identify deprecated or misconfigured actions.
Example
Extend to add validation for specific actions:
window.boostWidgetIntegration.extend('FilterHandler', (FilterHandler) => {
return class CustomFilterHandler extends FilterHandler {
handleAction(key, action, target) {
// Add validation before clearing filters
if (key === 'clearAllFilter') {
if (!confirm('Clear all filters?')) {
return; // Cancel action
}
}
// Add custom action type
if (key === 'customExport') {
this.filterHelper.emit('EXPORT_FILTERS', { action, target });
return;
}
super.handleAction(key, action, target);
}
};
});