fix: unusual behavior while scrolling through spotlight entries (#3324)

* fix: spotlight scroll issue

* fix: entry hidden issue

* chore: back to loop mode
This commit is contained in:
Anwarul Islam
2023-09-12 13:12:44 +06:00
committed by GitHub
parent 005581ee7d
commit dd143c95a9
2 changed files with 26 additions and 6 deletions

View File

@@ -40,7 +40,7 @@
:key="`result-${result.id}`"
:entry="result"
:active="isEqual(selectedEntry, [sectionIndex, entryIndex])"
@mouseover="selectedEntry = [sectionIndex, entryIndex]"
@mouseover="onMouseOver($event, sectionIndex, entryIndex)"
@action="runAction(sectionID, result)"
/>
</div>
@@ -178,6 +178,24 @@ function runAction(searcherID: string, result: SpotlightSearcherResult) {
emit("hide-modal")
}
let lastMousePosition: { x: number; y: number }
const onMouseOver = (
e: MouseEvent,
sectionIndex: number,
entryIndex: number
) => {
const mousePosition = {
x: e.clientX,
y: e.clientY,
}
// if the position is same, do nothing
if (isEqual(lastMousePosition, mousePosition)) return
selectedEntry.value = [sectionIndex, entryIndex]
lastMousePosition = mousePosition
}
function newUseArrowKeysForNavigation() {
const selectedEntry = ref<[number, number]>([0, 0]) // [sectionIndex, entryIndex]