diff --git a/client/components/Chat.vue b/client/components/Chat.vue
index e7762842..603aed8b 100644
--- a/client/components/Chat.vue
+++ b/client/components/Chat.vue
@@ -20,6 +20,7 @@
{{ channel.name }}
{
+ this.$refs.topicInput.focus();
+ });
+ }
+ },
},
mounted() {
this.channelChanged();
+
+ if (this.channel.editTopic) {
+ this.$nextTick(() => {
+ this.$refs.topicInput.focus();
+ });
+ }
},
methods: {
channelChanged() {
@@ -164,15 +178,11 @@ export default {
editTopic() {
if (this.channel.type === "channel") {
this.channel.editTopic = true;
-
- this.$nextTick(() => {
- document.querySelector(`#chan-${this.channel.id} .topic-input`).focus();
- });
}
},
saveTopic() {
this.channel.editTopic = false;
- const newTopic = document.querySelector(`#chan-${this.channel.id} .topic-input`).value;
+ const newTopic = this.$refs.topicInput.value;
if (this.channel.topic !== newTopic) {
const target = this.channel.id;
diff --git a/client/js/helpers/contextMenu.js b/client/js/helpers/contextMenu.js
index a9818a0f..5c7d9066 100644
--- a/client/js/helpers/contextMenu.js
+++ b/client/js/helpers/contextMenu.js
@@ -98,10 +98,6 @@ export function generateChannelContextMenu($root, channel, network) {
action() {
channel.editTopic = true;
$root.switchToChannel(channel);
-
- $root.$nextTick(() =>
- document.querySelector(`#chan-${channel.id} .topic-input`).focus()
- );
},
});
items.push({