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:
@@ -80,11 +80,10 @@ const props = defineProps<{
|
|||||||
active: boolean
|
active: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const formattedShortcutKeys = computed(
|
const formattedShortcutKeys = computed(() =>
|
||||||
() =>
|
props.entry.meta?.keyboardShortcut?.map((key) => {
|
||||||
props.entry.meta?.keyboardShortcut?.map((key) => {
|
return SPECIAL_KEY_CHARS[key] ?? capitalize(key)
|
||||||
return SPECIAL_KEY_CHARS[key] ?? capitalize(key)
|
})
|
||||||
})
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@@ -119,5 +118,8 @@ watch(
|
|||||||
&.active {
|
&.active {
|
||||||
@apply after:bg-accentLight;
|
@apply after:bg-accentLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scroll-padding: 4rem !important;
|
||||||
|
scroll-margin: 4rem !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
:key="`result-${result.id}`"
|
:key="`result-${result.id}`"
|
||||||
:entry="result"
|
:entry="result"
|
||||||
:active="isEqual(selectedEntry, [sectionIndex, entryIndex])"
|
:active="isEqual(selectedEntry, [sectionIndex, entryIndex])"
|
||||||
@mouseover="selectedEntry = [sectionIndex, entryIndex]"
|
@mouseover="onMouseOver($event, sectionIndex, entryIndex)"
|
||||||
@action="runAction(sectionID, result)"
|
@action="runAction(sectionID, result)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -178,6 +178,24 @@ function runAction(searcherID: string, result: SpotlightSearcherResult) {
|
|||||||
emit("hide-modal")
|
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() {
|
function newUseArrowKeysForNavigation() {
|
||||||
const selectedEntry = ref<[number, number]>([0, 0]) // [sectionIndex, entryIndex]
|
const selectedEntry = ref<[number, number]>([0, 0]) // [sectionIndex, entryIndex]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user