Fix focusing on firefox

This commit is contained in:
fayazara 2022-12-15 19:13:41 +05:30
parent 785b303166
commit ed8929b55c
2 changed files with 23 additions and 50 deletions

View file

@ -1,23 +0,0 @@
<template>
<div />
</template>
<script>
export default {
mounted() {
this.handler = event => {
event.preventDefault();
this.$emit('keyup', event);
};
window.addEventListener('keyup', this.handler);
},
beforeDestroy() {
window.removeEventListener('keyup', this.handler);
},
};
</script>
<style scoped>
div {
display: none;
}
</style>

View file

@ -1,6 +1,4 @@
<template>
<div>
<search-focus @keyup="focusSearch" />
<div class="input-container">
<div class="icon-container">
<fluent-icon icon="search" class="icon" aria-hidden="true" />
@ -16,16 +14,10 @@
<span>{{ $t('SEARCH.PLACEHOLDER_KEYBINDING') }}</span>
</div>
</div>
</div>
</template>
<script>
import SearchFocus from './SearchFocus.vue';
export default {
components: {
SearchFocus,
},
data() {
return {
searchQuery: '',
@ -33,6 +25,16 @@ export default {
},
mounted() {
this.$refs.searchInput.focus();
this.handler = e => {
if (e.key === '/') {
e.preventDefault();
this.$refs.searchInput.focus();
}
};
document.addEventListener('keydown', this.handler);
},
beforeDestroy() {
window.removeEventListener('keydown', this.handler);
},
methods: {
debounceSearch(e) {
@ -44,12 +46,6 @@ export default {
}
}, 500);
},
focusSearch(e) {
if (e.key === '/') {
e.preventDefault();
this.$refs.searchInput.focus();
}
},
},
};
</script>