Skip to content

Commit

Permalink
Habitable behaviour when user presses back button while search line i…
Browse files Browse the repository at this point in the history
…n CollapsedSearch has focus
  • Loading branch information
nkonev committed Nov 1, 2023
1 parent 5908769 commit 9c78246
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions frontend/src/CollapsedSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

<script>
import {hasLength} from "@/utils";
const VIEWPORT_VS_CLIENT_HEIGHT_RATIO = 0.75;
export default {
props: [
Expand All @@ -44,6 +45,28 @@ export default {
hasSearchString() {
return hasLength(this.provider.getModelValue())
},
reactOnKeyboardChange(event) {
if (
(event.target.height * event.target.scale) / window.screen.height <
VIEWPORT_VS_CLIENT_HEIGHT_RATIO
) {
console.log('keyboard is shown');
} else {
console.log('keyboard is hidden');
// close search line when user on mobile presses Back button
this.provider.setShowSearchButton(true);
}
},
},
mounted() {
if ('visualViewport' in window) {
window.visualViewport.addEventListener('resize', this.reactOnKeyboardChange);
}
},
beforeUnmount() {
if ('visualViewport' in window) {
window.visualViewport.removeEventListener('resize', this.reactOnKeyboardChange);
}
},
}
</script>
Expand Down

0 comments on commit 9c78246

Please sign in to comment.