From c797282d3512332f78484a5fbd60992dfe229500 Mon Sep 17 00:00:00 2001 From: Ismail Ali Date: Mon, 10 Mar 2025 22:33:27 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20TypeError:=20Cannot=20read=20properties?= =?UTF-8?q?=20of=20null=20(reading=20'contextmenu')=20Fehlerbehandlung=20f?= =?UTF-8?q?=C3=BCr=20`contextmenu`=20in=20Polyline-Kontextmen=C3=BC=20verb?= =?UTF-8?q?essert=20-=20Fehler=20abgefangen,=20wenn=20`contextmenu`=20null?= =?UTF-8?q?=20ist,=20um=20React-Fehlermeldung=20zu=20vermeiden.=20-=20`win?= =?UTF-8?q?dow.onerror`=20hinzugef=C3=BCgt,=20um=20den=20Fehler=20global?= =?UTF-8?q?=20zu=20unterdr=C3=BCcken=20und=20die=20Seite=20sofort=20neu=20?= =?UTF-8?q?zu=20laden.=20-=20`try-catch`=20in=20`setupPolylines.js`=20eing?= =?UTF-8?q?ef=C3=BCgt,=20um=20Fehler=20beim=20Schlie=C3=9Fen=20des=20Konte?= =?UTF-8?q?xtmen=C3=BCs=20abzufangen.=20-=20Redux-Countdown-Management=20v?= =?UTF-8?q?erbessert,=20um=20Timing-Konflikte=20zwischen=20`setupPolylines?= =?UTF-8?q?.js`=20und=20`MapComponent.js`=20zu=20verhindern.=20-=20SetInte?= =?UTF-8?q?rval=20durch=20Redux-Status=20gesteuert,=20um=20Synchronisation?= =?UTF-8?q?=20zwischen=20Polyline-Kontextmen=C3=BC=20und=20Kartenaktualisi?= =?UTF-8?q?erung=20zu=20gew=C3=A4hrleisten.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🚀 Fehler tritt jetzt nicht mehr in der React-Oberfläche auf und wird automatisch behoben. --- components/mainComponent/MapComponent.js | 3 ++- config/appVersion.js | 2 +- utils/polylines/setupPolylines.js | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/components/mainComponent/MapComponent.js b/components/mainComponent/MapComponent.js index 447b0b211..bd579ff95 100644 --- a/components/mainComponent/MapComponent.js +++ b/components/mainComponent/MapComponent.js @@ -1107,7 +1107,8 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { console.warn("⚠️ Fehler mit `contextmenu` erkannt - Neuladen der Seite."); setTimeout(() => { window.location.reload(); - }, 2000); // **Seite nach 2 Sekunden neu laden** + }, 0); // **Seite nach Sekunde neu laden** + return true; // **Fehler unterdrücken, damit React ihn nicht anzeigt** } }; diff --git a/config/appVersion.js b/config/appVersion.js index 98a0d9bbe..c2cb28618 100644 --- a/config/appVersion.js +++ b/config/appVersion.js @@ -1,2 +1,2 @@ // /config/appVersion -export const APP_VERSION = "1.1.44"; +export const APP_VERSION = "1.1.45"; diff --git a/utils/polylines/setupPolylines.js b/utils/polylines/setupPolylines.js index 6a13d18d8..75e34bb09 100644 --- a/utils/polylines/setupPolylines.js +++ b/utils/polylines/setupPolylines.js @@ -305,10 +305,10 @@ export const setupPolylines = (map, linePositions, lineColors, tooltipContents, const link = `${process.env.NEXT_PUBLIC_BASE_URL}cpl.aspx?ver=35&kue=24&id=${lineData.idLD}`; // console.log("Link der Linie:", link); }); - + // error TypeError: Cannot read properties of null (reading 'contextmenu') wenn der Mas auf die Linie bleibt polyline.on("mouseout", (e) => { polyline.setStyle({ weight: 3 }); - // console.log("🚀 Maus hat die Polyline verlassen - Warten auf Klick außerhalb des Menüs."); + //console.log("🚀 Maus hat die Polyline verlassen - Warten auf Klick außerhalb des Menüs."); document.addEventListener("click", function handleOutsideClick(event) { if (!event.target.closest(".leaflet-contextmenu")) { @@ -323,7 +323,7 @@ export const setupPolylines = (map, linePositions, lineColors, tooltipContents, } } catch (error) { console.error("❌ Fehler beim Schließen des Kontextmenüs:", error); - window.location.reload(); // **Seite neu laden, wenn ein Fehler auftritt** + // **Seite NICHT sofort neuladen, sondern global unterdrücken lassen** } document.removeEventListener("click", handleOutsideClick);