From 7cd2ce56d7bef3d86b0660c24cbf49e99e21fe9a Mon Sep 17 00:00:00 2001 From: legonzaur Date: Wed, 29 Mar 2023 21:51:21 +0200 Subject: [PATCH] fix funky player highlight behaviour on PlayerList --- src/components/PlayerList.vue | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/components/PlayerList.vue b/src/components/PlayerList.vue index 5b10ffa..cc01d8d 100644 --- a/src/components/PlayerList.vue +++ b/src/components/PlayerList.vue @@ -9,7 +9,7 @@ max distance average distance -
{{ index }}
{{ players[playerId].username }}
@@ -37,8 +37,7 @@ export default defineComponent({ return { sortingData: { direction: -1, argument: 'kills' as keyof Player | 'k/d' }, playerIdList: [] as string[], - store: useStore(), - selected: undefined as string | undefined + store: useStore() } }, computed: { @@ -52,24 +51,12 @@ export default defineComponent({ this.sortingData.direction *= -1 this.playerIdList = Object.keys(newval) this.sortPlayerList(this.sortingData.argument) - this.$nextTick(() => { - const element = (this.$refs['player:' + this.selected] as HTMLElement[]) - if (element && element.length > 0) element[0].classList.add('selected') - }) }, immediate: true }, - playerHighlighted (newval, oldval) { - const oldElement = this.$refs['player:' + oldval] as HTMLElement[] - if (oldElement) { - oldElement[0].classList.remove('selected') - delete this.selected - } + playerHighlighted (newval) { const newElement = this.$refs['player:' + newval] as HTMLElement[] - if (!newElement) return - newElement[0].classList.add('selected') newElement[0].scrollIntoView({ behavior: 'smooth', block: 'center' }) - this.selected = newval } }, updated () { @@ -121,10 +108,10 @@ export default defineComponent({ ArrowRight: 10, ArrowLeft: -10 } as { [key: string]: number } - if (!this.selected) return + if (!this.$props.playerHighlighted) return if (!Object.keys(values).includes(e.key)) return e.preventDefault() - const index = this.playerIdList.indexOf(this.selected) + const index = this.playerIdList.indexOf(this.$props.playerHighlighted) let nextIndex = (index + values[e.key]) if (nextIndex >= this.playerIdList.length) nextIndex = this.playerIdList.length - 1 if (nextIndex < 0) nextIndex = 0