diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2019-02-05 14:24:48 +0100 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2019-02-06 14:56:16 +0100 |
commit | 9a45c01253cb55e997d4930cd68175d51175375a (patch) | |
tree | 4e211363dbdc682f77290b454c3777c1d35e450f | |
parent | 0c05ffb94338349ff8924d7bfd7fa16a146a84e0 (diff) | |
download | gitlab-ce-winh-reply-button-focus.tar.gz |
Focus comment field when clicking reply to comment buttonwinh-reply-button-focus
-rw-r--r-- | app/assets/javascripts/notes/components/noteable_discussion.vue | 16 | ||||
-rw-r--r-- | app/assets/javascripts/notes/components/notes_app.vue | 7 |
2 files changed, 21 insertions, 2 deletions
diff --git a/app/assets/javascripts/notes/components/noteable_discussion.vue b/app/assets/javascripts/notes/components/noteable_discussion.vue index 653057c974b..7c22eee6a5f 100644 --- a/app/assets/javascripts/notes/components/noteable_discussion.vue +++ b/app/assets/javascripts/notes/components/noteable_discussion.vue @@ -26,6 +26,7 @@ import resolvable from '../mixins/resolvable'; import discussionNavigation from '../mixins/discussion_navigation'; import ReplyPlaceholder from './discussion_reply_placeholder.vue'; import jumpToNextDiscussionButton from './discussion_jump_to_next_button.vue'; +import eventHub from '../event_hub'; export default { name: 'NoteableDiscussion', @@ -245,6 +246,12 @@ export default { } }, }, + created() { + eventHub.$on('startReplying', this.onStartReplying); + }, + beforeDestroy() { + eventHub.$off('startReplying', this.onStartReplying); + }, methods: { ...mapActions([ 'saveNote', @@ -340,6 +347,13 @@ Please check your network connection and try again.`; deleteNoteHandler(note) { this.$emit('noteDeleted', this.discussion, note); }, + onStartReplying(discussionId) { + if (this.discussion.id !== discussionId) { + return; + } + + this.showReplyForm(); + }, }, }; </script> @@ -400,7 +414,7 @@ Please check your network connection and try again.`; :help-page-path="helpPagePath" :show-reply-button="canReply" @handleDeleteNote="deleteNoteHandler" - @startReplying="startReplying(discussion.id)" + @startReplying="showReplyForm" > <note-edited-text v-if="discussion.resolved" diff --git a/app/assets/javascripts/notes/components/notes_app.vue b/app/assets/javascripts/notes/components/notes_app.vue index 85e97cbd08f..862de92f1bc 100644 --- a/app/assets/javascripts/notes/components/notes_app.vue +++ b/app/assets/javascripts/notes/components/notes_app.vue @@ -180,6 +180,11 @@ export default { } } }, + startReplying(discussionId) { + return this.convertToDiscussion(discussionId) + .then(() => this.$nextTick()) + .then(() => eventHub.$emit('startReplying', discussionId)); + }, }, systemNote: constants.SYSTEM_NOTE, }; @@ -209,7 +214,7 @@ export default { :key="discussion.id" :note="discussion.notes[0]" :show-reply-button="canReply" - @startReplying="convertToDiscussion(discussion.id)" + @startReplying="startReplying(discussion.id)" /> </template> <noteable-discussion |