Home > widget-integration > InstantSearchController > cleanupBodyStyles
InstantSearchController.cleanupBodyStyles() method
Remove inline body styles that some themes apply via a native <dialog> scroll-lock mechanism (e.g. position: fixed; top: -scrollY; width: 100%).
These styles are NOT removed by clearing CSS classes, so they must be explicitly stripped as inline properties when ISW closes.
Override to restore or preserve specific properties for a given theme.
Signature:
protected cleanupBodyStyles(): void;
Returns:
void
Example
window.boostWidgetIntegration.extend('InstantSearchController', (InstantSearchController) => {
return class CustomController extends InstantSearchController {
protected cleanupBodyStyles() {
// Also restore scroll position lost by the fixed positioning
const scrollY = parseInt(document.body.style.top || '0', 10);
super.cleanupBodyStyles();
window.scrollTo(0, -scrollY);
}
};
});