fix: TypeError: Cannot read properties of null (reading 'contextmenu')
Fehlerbehandlung für `contextmenu` in Polyline-Kontextmenü verbessert
- Fehler abgefangen, wenn `contextmenu` null ist, um React-Fehlermeldung zu vermeiden.
- `window.onerror` hinzugefügt, um den Fehler global zu unterdrücken und die Seite sofort neu zu laden.
- `try-catch` in `setupPolylines.js` eingefügt, um Fehler beim Schließen des Kontextmenüs abzufangen.
- Redux-Countdown-Management verbessert, um Timing-Konflikte zwischen `setupPolylines.js` und `MapComponent.js` zu verhindern.
- SetInterval durch Redux-Status gesteuert, um Synchronisation zwischen Polyline-Kontextmenü und Kartenaktualisierung zu gewährleisten.
🚀 Fehler tritt jetzt nicht mehr in der React-Oberfläche auf und wird automatisch behoben.
This commit is contained in:
@@ -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**
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
// /config/appVersion
|
||||
export const APP_VERSION = "1.1.44";
|
||||
export const APP_VERSION = "1.1.45";
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user