Scroll search to top when focused

This commit is contained in:
play.js 2020-09-20 09:16:58 -05:00
parent f4bf6df4b1
commit 85c48a5b18

View file

@ -12,6 +12,7 @@
autofocus
autocomplete="off"
@keyup="queryResults(query)"
@focus="scrollInputToTop()"
>
<div class="search-input-separator border-white border-t-2" />
</div>
@ -93,6 +94,8 @@
</template>
<script>
import scrollIntoView from 'scroll-into-view-if-needed'
import appList from '~/assets/app-list.json'
// import overlayStore from './mixins/store'
@ -173,6 +176,12 @@ export default {
array.splice(index, 1)
return pluckedItem
},
scrollInputToTop () {
scrollIntoView(this.$refs['search'], {
block: 'start',
behavior: 'smooth'
})
},
queryResults (rawQuery) {
// Clear any results from before
this.titleStartsWithResults = []