mirror of
https://github.com/thelounge/thelounge
synced 2024-11-26 14:00:21 +00:00
Merge pull request #4364 from thelounge/maxleiter/escCloseSearch
Allow escape key to close search bar and search page
This commit is contained in:
commit
6dfd51bb57
2 changed files with 8 additions and 0 deletions
|
@ -9,6 +9,7 @@
|
||||||
class="input"
|
class="input"
|
||||||
placeholder="Search messages…"
|
placeholder="Search messages…"
|
||||||
@blur="closeSearch"
|
@blur="closeSearch"
|
||||||
|
@keyup.esc="closeSearch"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
|
@ -113,6 +114,7 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
closeSearch() {
|
closeSearch() {
|
||||||
if (!this.onSearchPage) {
|
if (!this.onSearchPage) {
|
||||||
|
this.searchInput = "";
|
||||||
this.searchOpened = false;
|
this.searchOpened = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -93,6 +93,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import socket from "../../js/socket";
|
import socket from "../../js/socket";
|
||||||
|
import eventbus from "../../js/eventbus";
|
||||||
|
|
||||||
import SidebarToggle from "../SidebarToggle.vue";
|
import SidebarToggle from "../SidebarToggle.vue";
|
||||||
import Message from "../Message.vue";
|
import Message from "../Message.vue";
|
||||||
|
@ -171,11 +172,16 @@ export default {
|
||||||
mounted() {
|
mounted() {
|
||||||
this.setActiveChannel();
|
this.setActiveChannel();
|
||||||
this.doSearch();
|
this.doSearch();
|
||||||
|
|
||||||
|
eventbus.on("escapekey", this.closeSearch);
|
||||||
this.$root.$on("re-search", this.doSearch); // Enable MessageSearchForm to search for the same query again
|
this.$root.$on("re-search", this.doSearch); // Enable MessageSearchForm to search for the same query again
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
this.$root.$off("re-search");
|
this.$root.$off("re-search");
|
||||||
},
|
},
|
||||||
|
destroyed() {
|
||||||
|
eventbus.off("escapekey", this.closeSearch);
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
setActiveChannel() {
|
setActiveChannel() {
|
||||||
this.$store.commit("activeChannel", this.chan);
|
this.$store.commit("activeChannel", this.chan);
|
||||||
|
|
Loading…
Reference in a new issue