From 38dcb521a1abb10a59d336d490c5fd2ea62ef1b7 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Wed, 22 Aug 2018 12:55:23 +0900 Subject: [PATCH] refs #543 Fix focus logic in tag --- .../TimelineSpace/Contents/Hashtag/Tag.vue | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/renderer/components/TimelineSpace/Contents/Hashtag/Tag.vue b/src/renderer/components/TimelineSpace/Contents/Hashtag/Tag.vue index 172336f2..a4b868d5 100644 --- a/src/renderer/components/TimelineSpace/Contents/Hashtag/Tag.vue +++ b/src/renderer/components/TimelineSpace/Contents/Hashtag/Tag.vue @@ -4,11 +4,11 @@
-
+
= 0 && this.heading) { + focusedId: function (newState, oldState) { + if (newState && this.heading) { this.$store.commit('TimelineSpace/Contents/Hashtag/Tag/changeHeading', false) } else if (newState === null && !this.heading) { this.$store.commit('TimelineSpace/Contents/Hashtag/Tag/changeHeading', true) @@ -185,24 +185,26 @@ export default { document.getElementById('scrollable'), 0 ) - this.focusedIndex = null + this.focusedId = null }, focusNext () { - if (this.focusedIndex === null) { - this.focusedIndex = 0 - } else if (this.focusedIndex < this.timeline.length) { - this.focusedIndex++ + const currentIndex = this.timeline.findIndex(toot => this.focusedId === toot.uri) + if (currentIndex === -1) { + this.focusedId = this.timeline[0].uri + } else if (currentIndex < this.timeline.length) { + this.focusedId = this.timeline[currentIndex + 1].uri } }, focusPrev () { - if (this.focusedIndex === 0) { - this.focusedIndex = null - } else if (this.focusedIndex > 0) { - this.focusedIndex-- + const currentIndex = this.timeline.findIndex(toot => this.focusedId === toot.uri) + if (currentIndex === 0) { + this.focusedId = null + } else if (currentIndex > 0) { + this.focusedId = this.timeline[currentIndex - 1].uri } }, - focusToot (index) { - this.focusedIndex = index + focusToot (message) { + this.focusedId = message.uri } } }