unmount un delete

This commit is contained in:
Georges-Antoine Assi
2025-08-27 19:28:42 -04:00
parent b5f3ad6b0f
commit 94ff330a4b
2 changed files with 27 additions and 19 deletions

View File

@@ -298,7 +298,7 @@ function onFilterClick(filter: FilterType, value: string) {
</v-row>
</template>
<v-row v-if="rom.is_identified">
<v-col cols="12" class="mt-4 text-right">
<v-col class="mt-4 text-right">
<div class="text-grey">
Data provided by
<template v-for="(source, index) in dataSources" :key="source.name">

View File

@@ -24,10 +24,12 @@ import {
watch,
defineAsyncComponent,
onMounted,
onBeforeUnmount,
} from "vue";
import { useRoute, useRouter } from "vue-router";
import { useDisplay } from "vuetify";
import { useI18n } from "vue-i18n";
// Dynamic import for PDFViewer
const PdfViewer = defineAsyncComponent(
() => import("@/components/Details/PDFViewer.vue"),
@@ -69,6 +71,25 @@ async function fetchDetails() {
});
}
function handleKeyDown(event: KeyboardEvent) {
if (event.key === "ArrowLeft") {
const currentIndex = filteredRoms.value.findIndex(
(rom) => rom.id === currentRom.value?.id,
);
if (currentIndex > 0) {
router.push(`/rom/${filteredRoms.value[currentIndex - 1].id}`);
}
}
if (event.key === "ArrowRight") {
const currentIndex = filteredRoms.value.findIndex(
(rom) => rom.id === currentRom.value?.id,
);
if (currentIndex < filteredRoms.value.length - 1) {
router.push(`/rom/${filteredRoms.value[currentIndex + 1].id}`);
}
}
}
onBeforeMount(async () => {
const romId = parseInt(route.params.rom as string);
@@ -93,24 +114,11 @@ onBeforeMount(async () => {
});
onMounted(() => {
document.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") {
const currentIndex = filteredRoms.value.findIndex(
(rom) => rom.id === currentRom.value?.id,
);
if (currentIndex > 0) {
router.push(`/rom/${filteredRoms.value[currentIndex - 1].id}`);
}
}
if (event.key === "ArrowRight") {
const currentIndex = filteredRoms.value.findIndex(
(rom) => rom.id === currentRom.value?.id,
);
if (currentIndex < filteredRoms.value.length - 1) {
router.push(`/rom/${filteredRoms.value[currentIndex + 1].id}`);
}
}
});
document.addEventListener("keydown", handleKeyDown);
});
onBeforeUnmount(() => {
document.removeEventListener("keydown", handleKeyDown);
});
watch(