fix(search): fix some small bugs

This commit is contained in:
Valentin Kaelin 2020-08-25 16:36:36 +02:00
parent 2a03163a14
commit b3b27d0223
2 changed files with 10 additions and 3 deletions

View file

@ -58,6 +58,7 @@
<SearchFormDropdownPlayer <SearchFormDropdownPlayer
v-for="(player, index) in recentSearchesSliced" v-for="(player, index) in recentSearchesSliced"
:key="player.name + player.region" :key="player.name + player.region"
@close="close"
@mousemove.native="onHover(index + 1)" @mousemove.native="onHover(index + 1)"
:selected="index === selected - 1" :selected="index === selected - 1"
:player="player" :player="player"
@ -66,6 +67,7 @@
</template> </template>
<template v-else-if="favorites.length === 0"> <template v-else-if="favorites.length === 0">
<SearchFormDropdownPlayer <SearchFormDropdownPlayer
@close="close"
@mousemove.native="onHover(1)" @mousemove.native="onHover(1)"
:player="{name: 'Alderiate', icon: 1150, region: 'euw'}" :player="{name: 'Alderiate', icon: 1150, region: 'euw'}"
:selected="selected === 1" :selected="selected === 1"
@ -87,6 +89,7 @@
<SearchFormDropdownPlayer <SearchFormDropdownPlayer
v-for="(player, index) in favorites" v-for="(player, index) in favorites"
:key="player.name + player.region" :key="player.name + player.region"
@close="close"
@mousemove.native="onHover(index + recentSearchesCount + 1)" @mousemove.native="onHover(index + recentSearchesCount + 1)"
:player="player" :player="player"
:selected="index === selected - 1 - recentSearchesCount" :selected="index === selected - 1 - recentSearchesCount"
@ -246,12 +249,12 @@ export default {
this.selected = this.selected + 1 > this.totalCount ? 1 : this.selected + 1 this.selected = this.selected + 1 > this.totalCount ? 1 : this.selected + 1
this.onArrow() this.onArrow()
}, },
async onHover(id) { onHover(id) {
this.selected = id this.selected = id
if (this.$refs.searches !== document.activeElement) { if (this.$refs.searches && this.$refs.searches !== document.activeElement) {
await this.$nextTick()
this.$refs.searches.focus() this.$refs.searches.focus()
this.onArrow()
} }
}, },
onOptionSelect() { onOptionSelect() {

View file

@ -1,5 +1,6 @@
<template> <template>
<router-link <router-link
@click.native="close"
:to="{ name: 'summoner', params: { region: player.region, name: player.name }}" :to="{ name: 'summoner', params: { region: player.region, name: player.name }}"
:title="player.name" :title="player.name"
:class="selected ? 'bg-blue-760' : 'bg-blue-900'" :class="selected ? 'bg-blue-760' : 'bg-blue-900'"
@ -66,6 +67,9 @@ export default {
}, },
methods: { methods: {
close() {
this.$emit('close')
},
closeClick() { closeClick() {
if (this.favoritesList) { if (this.favoritesList) {
this.updateFavorite(this.player) this.updateFavorite(this.player)