feat: set active on hover + minor ui improvements

This commit is contained in:
liyasthomas
2021-10-19 13:40:47 +05:30
parent d872e393f8
commit fdfca00886
3 changed files with 13 additions and 31 deletions

View File

@@ -7,6 +7,7 @@
:active="shortcutIndex === selectedEntry"
:shortcut="shortcut.item"
@action="$emit('action', shortcut.item.action)"
@mouseover.native="selectedEntry = shortcutIndex"
/>
<div
v-if="searchResults.length === 0"
@@ -21,12 +22,7 @@
</template>
<script setup lang="ts">
import {
computed,
onUnmounted,
onMounted,
getCurrentInstance,
} from "@nuxtjs/composition-api"
import { computed, onUnmounted, onMounted } from "@nuxtjs/composition-api"
import Fuse from "fuse.js"
import { useArrowKeysNavigation } from "~/helpers/powerSearchNavigation"
import { HoppAction } from "~/helpers/actions"
@@ -36,6 +32,10 @@ const props = defineProps<{
search: string
}>()
const emit = defineEmits<{
(e: "action", action: HoppAction): void
}>()
const options = {
keys: ["keys", "label", "action", "tags"],
}
@@ -48,10 +48,7 @@ const searchResultsItems = computed(() =>
searchResults.value.map((searchResult: any) => searchResult.item)
)
const currentInstance = getCurrentInstance()
const emitSearchAction = (action: HoppAction) =>
currentInstance.emit("action", action)
const emitSearchAction = (action: HoppAction) => emit("action", action)
const { bindArrowKeysListerners, unbindArrowKeysListerners, selectedEntry } =
useArrowKeysNavigation(searchResultsItems, {