Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions modules/search/instant-search/components/search-app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class SearchApp extends Component {
this.getResults.flush();

this.addEventListeners();
this.preventBodyScroll();

if ( this.hasActiveQuery() ) {
this.showResults();
Expand All @@ -59,6 +60,7 @@ class SearchApp extends Component {

componentWillUnmount() {
this.removeEventListeners();
this.restoreBodyScroll();
}

addEventListeners() {
Expand Down Expand Up @@ -89,6 +91,14 @@ class SearchApp extends Component {
} );
}

preventBodyScroll() {
document.body.style.overflowY = 'hidden';
}

restoreBodyScroll() {
delete document.body.style.overflowY;
}

hasActiveQuery() {
return getSearchQuery() !== '' || hasFilter();
}
Expand Down