Skip to content

Commit

Permalink
Fix search box out of screen (#2650)
Browse files Browse the repository at this point in the history
Programatically set search results max height
  • Loading branch information
askvortsov1 committed Mar 7, 2021
1 parent 4b0ad69 commit 3aa118a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 7 additions & 0 deletions js/src/forum/components/Search.js
Expand Up @@ -113,6 +113,13 @@ export default class Search extends Component {
onupdate() {
// Highlight the item that is currently selected.
this.setIndex(this.getCurrentNumericIndex());

// Since extensions might add elements above the search box on mobile,
// we need to calculate and set the max height dynamically.
const resultsElementMargin = 14;
const maxHeight =
window.innerHeight - this.element.querySelector('.Search-input>.FormControl').getBoundingClientRect().bottom - resultsElementMargin;
this.element.querySelector('.Search-results').style['max-height'] = `${maxHeight}px`;
}

oncreate(vnode) {
Expand Down
1 change: 0 additions & 1 deletion less/common/Search.less
Expand Up @@ -15,7 +15,6 @@
}
}
.Search-results {
max-height: 70vh;
overflow: auto;
left: auto;
right: 0;
Expand Down

0 comments on commit 3aa118a

Please sign in to comment.