diff --git a/modules/search/instant-search/components/search-app.jsx b/modules/search/instant-search/components/search-app.jsx index 6662001a6ef1..7f1ff34fa6b9 100644 --- a/modules/search/instant-search/components/search-app.jsx +++ b/modules/search/instant-search/components/search-app.jsx @@ -51,6 +51,7 @@ class SearchApp extends Component { this.getResults.flush(); this.addEventListeners(); + this.preventBodyScroll(); if ( this.hasActiveQuery() ) { this.showResults(); @@ -59,6 +60,7 @@ class SearchApp extends Component { componentWillUnmount() { this.removeEventListeners(); + this.restoreBodyScroll(); } addEventListeners() { @@ -89,6 +91,14 @@ class SearchApp extends Component { } ); } + preventBodyScroll() { + document.body.style.overflowY = 'hidden'; + } + + restoreBodyScroll() { + delete document.body.style.overflowY; + } + hasActiveQuery() { return getSearchQuery() !== '' || hasFilter(); }