Fix memory leaks from Tippy.js instances and unremoved event listeners
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -75,6 +75,8 @@ const {
|
||||
conformanceFileName,
|
||||
} = storeToRefs(conformanceStore);
|
||||
|
||||
let loadingTimerId = null;
|
||||
|
||||
// Created logic
|
||||
(async () => {
|
||||
isLoading.value = true;
|
||||
@@ -109,7 +111,7 @@ const {
|
||||
} catch (error) {
|
||||
console.error("Failed to initialize conformance:", error);
|
||||
} finally {
|
||||
setTimeout(() => (isLoading.value = false), 500);
|
||||
loadingTimerId = setTimeout(() => (isLoading.value = false), 500);
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -124,6 +126,7 @@ onMounted(() => {
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
clearTimeout(loadingTimerId);
|
||||
conformanceLogId.value = null;
|
||||
conformanceFilterId.value = null;
|
||||
conformanceLogCreateCheckId.value = null;
|
||||
|
||||
@@ -465,7 +465,7 @@
|
||||
* and file operations (rename, delete).
|
||||
*/
|
||||
|
||||
import { ref, computed, watch, onMounted } from "vue";
|
||||
import { ref, computed, watch, onMounted, onBeforeUnmount } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useMapCompareStore } from "@/stores/mapCompareStore";
|
||||
@@ -917,19 +917,29 @@ function getGridSortData(event) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the active file selection when clicking outside a list item.
|
||||
* @param {MouseEvent} e - The click event.
|
||||
*/
|
||||
const handleWindowClick = (e) => {
|
||||
const clickedLi = e.target.closest("li");
|
||||
if (!clickedLi || !clickedLi.id.startsWith("li")) isActive.value = null;
|
||||
};
|
||||
|
||||
// Mounted
|
||||
onMounted(() => {
|
||||
isLoading.value = true;
|
||||
store.fetchAllFiles();
|
||||
window.addEventListener("click", (e) => {
|
||||
const clickedLi = e.target.closest("li");
|
||||
if (!clickedLi || !clickedLi.id.startsWith("li")) isActive.value = null;
|
||||
});
|
||||
window.addEventListener("click", handleWindowClick);
|
||||
// Add the .scrollbar class to the DataTable tbody
|
||||
const tbodyElement = document.querySelector(".p-datatable-tbody");
|
||||
tbodyElement?.classList.add("scrollbar");
|
||||
isLoading.value = false;
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener("click", handleWindowClick);
|
||||
});
|
||||
</script>
|
||||
<style scoped>
|
||||
@reference "../../assets/tailwind.css";
|
||||
|
||||
Reference in New Issue
Block a user