refactor: migrate more components to setup script + fix a race condition with power search
This commit is contained in:
@@ -15,17 +15,18 @@ export function useArrowKeysNavigation(searchItems: any, options: any = {}) {
|
||||
const itemsLength = searchItems.value.length
|
||||
const lastItemIndex = itemsLength - 1
|
||||
const itemIndexValue = itemIndex.value
|
||||
const action = searchItems.value[itemIndexValue].action
|
||||
const action = searchItems.value[itemIndexValue]?.action
|
||||
|
||||
if (action && event.key === "Enter" && options.onEnter) {
|
||||
options.onEnter(action)
|
||||
return
|
||||
}
|
||||
|
||||
if (event.key === "ArrowDown") {
|
||||
if (itemsLength && event.key === "ArrowDown") {
|
||||
itemIndex.value = itemIndexValue < lastItemIndex ? itemIndexValue + 1 : 0
|
||||
} else if (itemIndexValue === 0) itemIndex.value = lastItemIndex
|
||||
else if (event.key === "ArrowUp") itemIndex.value = itemIndexValue - 1
|
||||
else if (itemsLength && event.key === "ArrowUp")
|
||||
itemIndex.value = itemIndexValue - 1
|
||||
}
|
||||
|
||||
const preventPropagation = options && options.stopPropagation
|
||||
|
||||
Reference in New Issue
Block a user