refs #543 Fix focus logic in tag
This commit is contained in:
parent
9e17d42cac
commit
38dcb521a1
|
@ -4,11 +4,11 @@
|
|||
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
|
||||
</div>
|
||||
<transition-group name="timeline" tag="div">
|
||||
<div class="tag-timeline" v-for="(message, index) in timeline" v-bind:key="message.uri">
|
||||
<div class="tag-timeline" v-for="message in timeline" v-bind:key="message.uri">
|
||||
<toot
|
||||
:message="message"
|
||||
:filter="filter"
|
||||
:focused="index === focusedIndex"
|
||||
:focused="message.uri === focusedId"
|
||||
v-on:update="updateToot"
|
||||
v-on:delete="deleteToot"
|
||||
@focusNext="focusNext"
|
||||
|
@ -37,7 +37,7 @@ export default {
|
|||
props: ['tag'],
|
||||
data () {
|
||||
return {
|
||||
focusedIndex: null
|
||||
focusedId: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -76,8 +76,8 @@ export default {
|
|||
})
|
||||
}
|
||||
},
|
||||
focusedIndex: function (newState, oldState) {
|
||||
if (newState >= 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue