Skip to content

Commit

Permalink
Focus tree topic post reply editor when replying
Browse files Browse the repository at this point in the history
  • Loading branch information
danon committed Dec 17, 2024
1 parent 5c60af3 commit 63ce72f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions resources/js/components/forum/form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ export default {
this.originalText = this.post.text;
},
methods: {
focus(): void {
this.$refs.markdown.focus();
},
cancel() {
this.post.text = this.originalText;
this.$emit('cancel');
Expand Down
7 changes: 6 additions & 1 deletion resources/js/components/forum/post.vue
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@
<div class="d-none d-lg-block col-lg-2"/>
<div class="col-12 col-lg-10">
<div class="px-2 pb-2 ps-lg-0 pe-lg-4 pb-lg-3">
<vue-form :tree-answer-post-id="post.id" :post="postDefault" @save="formSaved"/>
<vue-form :tree-answer-post-id="post.id" :post="postDefault" @save="formSaved" ref="topicReply"/>
</div>
</div>
</div>
Expand Down Expand Up @@ -514,6 +514,11 @@ export default {
replyQuoteContent(): void {
if (store.getters['topics/is_mode_tree']) {
this.$data.treeTopicReplyVisible = !this.$data.treeTopicReplyVisible;
if (this.$data.treeTopicReplyVisible) {
nextTick(() => {
this.$refs.topicReply.focus();
});
}
} else {
this.$emit('reply', this.$props.post, false);
}
Expand Down

0 comments on commit 63ce72f

Please sign in to comment.