Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unusual behavior while scrolling through spotlight entries #3324

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -80,11 +80,10 @@ const props = defineProps<{
active: boolean
}>()

const formattedShortcutKeys = computed(
() =>
props.entry.meta?.keyboardShortcut?.map((key) => {
return SPECIAL_KEY_CHARS[key] ?? capitalize(key)
})
const formattedShortcutKeys = computed(() =>
props.entry.meta?.keyboardShortcut?.map((key) => {
return SPECIAL_KEY_CHARS[key] ?? capitalize(key)
})
)

const emit = defineEmits<{
Expand Down Expand Up @@ -119,5 +118,8 @@ watch(
&.active {
@apply after:bg-accentLight;
}

scroll-padding: 4rem !important;
scroll-margin: 4rem !important;
}
</style>
Expand Up @@ -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>
Expand Down Expand Up @@ -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]

Expand Down