From 42cec2d67d95c3a74e1545577ff1bdb15e1e51b2 Mon Sep 17 00:00:00 2001 From: Daniel Wilkowski Date: Tue, 6 Feb 2024 17:59:37 +0100 Subject: [PATCH] Encapsulate VueCommentForm.focus() --- resources/js/components/forum/comment-form.vue | 4 ++++ resources/js/components/forum/comment.vue | 2 +- resources/js/components/forum/post.vue | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/resources/js/components/forum/comment-form.vue b/resources/js/components/forum/comment-form.vue index 990050742..d56c28885 100644 --- a/resources/js/components/forum/comment-form.vue +++ b/resources/js/components/forum/comment-form.vue @@ -72,6 +72,10 @@ export default class VueCommentForm extends Vue { .finally(() => this.isProcessing = false); } + focus() { + this.textarea.focus(); + } + cancel() { this.$emit('cancel'); } diff --git a/resources/js/components/forum/comment.vue b/resources/js/components/forum/comment.vue index 964a05d74..7e67d8bb3 100644 --- a/resources/js/components/forum/comment.vue +++ b/resources/js/components/forum/comment.vue @@ -58,7 +58,7 @@ this.$store.commit('posts/edit', this.comment); if (this.comment.is_editing) { - this.$nextTick(() => this.commentForm.textarea.focus()); + this.$nextTick(() => this.commentForm.focus()); } } diff --git a/resources/js/components/forum/post.vue b/resources/js/components/forum/post.vue index 7271ae12c..0674c2eae 100644 --- a/resources/js/components/forum/post.vue +++ b/resources/js/components/forum/post.vue @@ -413,7 +413,7 @@ export default class VuePost extends Vue { if (this.isCommenting) { // @ts-ignore - this.$nextTick(() => this.commentForm.textarea.focus()); + this.$nextTick(() => this.commentForm.focus()); } }