diff --git a/client/components/ChatInput.vue b/client/components/ChatInput.vue index d12b9405..f0dbb14b 100644 --- a/client/components/ChatInput.vue +++ b/client/components/ChatInput.vue @@ -183,6 +183,10 @@ export default { }, setInputSize() { this.$nextTick(() => { + if (!this.$refs.input) { + return; + } + const style = window.getComputedStyle(this.$refs.input); const lineHeight = parseFloat(style.lineHeight, 10) || 1; diff --git a/client/components/MessageSearchForm.vue b/client/components/MessageSearchForm.vue index 233e099f..340d7e2d 100644 --- a/client/components/MessageSearchForm.vue +++ b/client/components/MessageSearchForm.vue @@ -104,6 +104,10 @@ export default { mounted() { this.searchInput = this.$route.query.q; this.searchOpened = this.onSearchPage; + + if (!this.searchInput) { + this.$refs.searchInputField.focus(); + } }, methods: { closeSearch() { diff --git a/client/components/Windows/Help.vue b/client/components/Windows/Help.vue index 7305b1ec..8015bbf8 100644 --- a/client/components/Windows/Help.vue +++ b/client/components/Windows/Help.vue @@ -673,6 +673,15 @@ +
+
+ /search query +
+
+

Search for messages in the current channel / user

+
+
+
/topic [newtopic] diff --git a/client/js/commands/search.js b/client/js/commands/search.js new file mode 100644 index 00000000..31e8c49b --- /dev/null +++ b/client/js/commands/search.js @@ -0,0 +1,20 @@ +"use strict"; + +import store from "../store"; +import {router} from "../router"; + +function input(args) { + router.push({ + name: "SearchResults", + params: { + id: store.state.activeChannel.channel.id, + }, + query: { + q: args.join(" "), + }, + }); + + return true; +} + +export default {input}; diff --git a/src/plugins/inputs/index.js b/src/plugins/inputs/index.js index 911d06cb..5f012254 100644 --- a/src/plugins/inputs/index.js +++ b/src/plugins/inputs/index.js @@ -1,4 +1,4 @@ -const clientSideCommands = ["/collapse", "/expand"]; +const clientSideCommands = ["/collapse", "/expand", "/search"]; const passThroughCommands = [ "/as",