Scroll to top of list when searching players
This commit is contained in:
parent
14e67571b2
commit
9265f8a02a
@ -15,7 +15,7 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<input v-if="filteredPlayers && search" class="section__search" type="text" name="search"
|
<input ref="searchInput" v-if="filteredPlayers && search" class="section__search" type="text" name="search"
|
||||||
v-model="searchQuery" :placeholder="messagePlayersSearchPlaceholder" @keydown="onKeydown">
|
v-model="searchQuery" :placeholder="messagePlayersSearchPlaceholder" @keydown="onKeydown">
|
||||||
<RadioList v-if="filteredPlayers.length" :aria-labelledby="ariaLabelledby">
|
<RadioList v-if="filteredPlayers.length" :aria-labelledby="ariaLabelledby">
|
||||||
<PlayerListItem v-for="player in filteredPlayers" :key="player.name" :player="player"></PlayerListItem>
|
<PlayerListItem v-for="player in filteredPlayers" :key="player.name" :player="player"></PlayerListItem>
|
||||||
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import PlayerListItem from "./PlayerListItem.vue";
|
import PlayerListItem from "./PlayerListItem.vue";
|
||||||
import {computed, defineComponent} from "@vue/runtime-core";
|
import {computed, defineComponent, watch} from "@vue/runtime-core";
|
||||||
import RadioList from "@/components/util/RadioList.vue";
|
import RadioList from "@/components/util/RadioList.vue";
|
||||||
import {LiveAtlasPlayer} from "@/index";
|
import {LiveAtlasPlayer} from "@/index";
|
||||||
import {useStore} from "@/store";
|
import {useStore} from "@/store";
|
||||||
@ -59,6 +59,7 @@ export default defineComponent({
|
|||||||
messagePlayersSearchPlaceholder = computed(() => store.state.messages.playersSearchPlaceholder),
|
messagePlayersSearchPlaceholder = computed(() => store.state.messages.playersSearchPlaceholder),
|
||||||
|
|
||||||
searchQuery = ref(""),
|
searchQuery = ref(""),
|
||||||
|
searchInput = ref<HTMLInputElement | null>(null),
|
||||||
|
|
||||||
filteredPlayers = computed(() => {
|
filteredPlayers = computed(() => {
|
||||||
const query = searchQuery.value.toLowerCase();
|
const query = searchQuery.value.toLowerCase();
|
||||||
@ -72,12 +73,15 @@ export default defineComponent({
|
|||||||
e.stopImmediatePropagation();
|
e.stopImmediatePropagation();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
watch(searchQuery, () => searchInput.value!.nextElementSibling!.scrollIntoView());
|
||||||
|
|
||||||
return {
|
return {
|
||||||
messageSkeletonPlayers,
|
messageSkeletonPlayers,
|
||||||
messageSkeletonPlayersSearch,
|
messageSkeletonPlayersSearch,
|
||||||
messagePlayersSearchPlaceholder,
|
messagePlayersSearchPlaceholder,
|
||||||
|
|
||||||
searchQuery,
|
searchQuery,
|
||||||
|
searchInput,
|
||||||
|
|
||||||
filteredPlayers,
|
filteredPlayers,
|
||||||
onKeydown
|
onKeydown
|
||||||
|
@ -54,3 +54,9 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
::v-deep(.menu) {
|
||||||
|
scroll-margin-top: 8.2rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user