Replaced .then() with await

This commit is contained in:
Simon Cambier
2022-04-26 19:59:04 +02:00
parent e943f39f42
commit 02e45b80cc
2 changed files with 12 additions and 14 deletions

View File

@@ -92,11 +92,10 @@ function moveIndex(dir: 1 | -1): void {
scrollIntoView()
}
function scrollIntoView(): void {
tick().then(() => {
async function scrollIntoView(): Promise<void> {
await tick()
const elem = document.querySelector(`[data-result-id="${selectedIndex}"]`)
elem?.scrollIntoView({ behavior: "auto", block: "nearest" })
})
}
async function openSelection(): Promise<void> {

View File

@@ -78,15 +78,14 @@ function moveIndex(dir: 1 | -1): void {
scrollIntoView()
}
function scrollIntoView(): void {
tick().then(() => {
async function scrollIntoView(): Promise<void> {
await tick()
if (selectedNote) {
const elem = document.querySelector(
`[data-result-id="${selectedNote.path}"]`
)
elem?.scrollIntoView({ behavior: "auto", block: "nearest" })
}
})
}
</script>