Home > widget-integration > FilterHandler > handleClickOutsideMiniPopup
FilterHandler.handleClickOutsideMiniPopup() method
Handles clicks outside the quick add to cart mini popup to close it.
Closes any open quick cart selection popup when clicking outside of it, except when clicking the select option button itself. This provides a better user experience by allowing easy dismissal of the popup. Override this method to customize popup closing behavior or add additional close triggers.
Signature:
handleClickOutsideMiniPopup(target: HTMLElement): void;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
target |
HTMLElement |
The clicked DOM element |
Returns:
void
Example
Extend to add animation before closing:
window.boostWidgetIntegration.extend('FilterHandler', (FilterHandler) => {
return class CustomFilterHandler extends FilterHandler {
handleClickOutsideMiniPopup(target) {
const miniPopupOpening = document.querySelector(
'.boost-sd__popup-select-option[style="display: block;"]'
);
if (miniPopupOpening && !target.closest('.boost-sd__button--select-option')) {
// Add fade-out animation before closing
miniPopupOpening.classList.add('fade-out');
setTimeout(() => {
super.handleClickOutsideMiniPopup(target);
}, 200);
return;
}
super.handleClickOutsideMiniPopup(target);
}
};
});