diff --git a/client/components/Chat.vue b/client/components/Chat.vue index 14755306..b635530e 100644 --- a/client/components/Chat.vue +++ b/client/components/Chat.vue @@ -93,6 +93,19 @@ export default { network: Object, channel: Object, }, + watch: { + "channel.messages"() { + const el = this.$refs.chat; + + if (el.scrollHeight - el.scrollTop - el.offsetHeight > 30) { + return; + } + + this.$nextTick(() => { + el.scrollTop = el.scrollHeight; + }); + }, + }, created() { if (window.IntersectionObserver) { this.historyObserver = new window.IntersectionObserver(loadMoreHistory, { @@ -114,19 +127,6 @@ export default { this.historyObserver.disconnect(); } }, - watch: { - "channel.messages": function() { - const el = this.$refs.chat; - - if (el.scrollHeight - el.scrollTop - el.offsetHeight > 30) { - return; - } - - this.$nextTick(() => { - el.scrollTop = el.scrollHeight; - }); - } - }, methods: { onShowMoreClick() { let lastMessage = this.channel.messages[0]; diff --git a/client/components/ChatInput.vue b/client/components/ChatInput.vue index 9129b644..86dedee5 100644 --- a/client/components/ChatInput.vue +++ b/client/components/ChatInput.vue @@ -13,7 +13,7 @@ :aria-label="getInputPlaceholder(channel)" :disabled="!$root.connected" class="mousetrap" - @keyup.enter="onSubmit" + @keypress.enter.prevent="onSubmit" /> {{ param }} + :key="id">{{ param }}