Adding logic to prevent virtual keyboards (#2667)

from closing the search bar
This commit is contained in:
Emma 2022-10-03 22:54:31 -04:00 committed by GitHub
parent 1645ab0889
commit 4a70726216
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -76,6 +76,7 @@ export default Vue.extend({
}
},
mounted: function () {
let previousWidth = window.innerWidth
if (window.innerWidth <= 680) {
this.showSearchContainer = false
}
@ -88,7 +89,12 @@ export default Vue.extend({
}, 0)
window.addEventListener('resize', () => {
this.showSearchContainer = window.innerWidth > 680
// Don't change the status of showSearchContainer if only the height of the window changes
// Opening the virtual keyboard can trigger this resize event, but it won't change the width
if (previousWidth !== window.innerWidth) {
this.showSearchContainer = window.innerWidth > 680
previousWidth = window.innerWidth
}
})
this.debounceSearchResults = debounce(this.getSearchSuggestions, 200)