From f44323495db8c61c295202142fa4253bf20371a3 Mon Sep 17 00:00:00 2001
From: Sven Verweij <37927107+SvenVw@users.noreply.github.com>
Date: Fri, 5 Dec 2025 16:41:12 +0100
Subject: [PATCH 1/2] Fix: saved fields of the farm are visible again with a
colored outline
---
.changeset/nice-clocks-rush.md | 5 ++++
.../components/blocks/atlas/atlas-panels.tsx | 29 ++++++++++++-------
..._id_farm.$calendar.atlas.fields._index.tsx | 24 +++++++++++++--
...farm.create.$b_id_farm.$calendar.atlas.tsx | 10 +++++--
4 files changed, 52 insertions(+), 16 deletions(-)
create mode 100644 .changeset/nice-clocks-rush.md
diff --git a/.changeset/nice-clocks-rush.md b/.changeset/nice-clocks-rush.md
new file mode 100644
index 000000000..be6ad36de
--- /dev/null
+++ b/.changeset/nice-clocks-rush.md
@@ -0,0 +1,5 @@
+---
+"@svenvw/fdm-app": patch
+---
+
+Fixes that saved fields of the farm are visible again with a colored outline
diff --git a/fdm-app/app/components/blocks/atlas/atlas-panels.tsx b/fdm-app/app/components/blocks/atlas/atlas-panels.tsx
index 9364da301..6fb474911 100644
--- a/fdm-app/app/components/blocks/atlas/atlas-panels.tsx
+++ b/fdm-app/app/components/blocks/atlas/atlas-panels.tsx
@@ -38,22 +38,29 @@ export function FieldsPanelHover({
// Set message about zoom level
const zoom = map.getZoom()
if (zoom && zoom > zoomLevelFields) {
+ if (!map.getLayer(layer)) return
+
const features = map.queryRenderedFeatures(evt.point, {
layers: [layer],
})
if (layerExclude) {
- const featuresExclude = map.queryRenderedFeatures(
- evt.point,
- {
- layers: Array.isArray(layerExclude)
- ? layerExclude
- : [layerExclude],
- },
- )
- if (featuresExclude && featuresExclude.length > 0) {
- setPanel(null)
- return
+ const layers = Array.isArray(layerExclude)
+ ? layerExclude
+ : [layerExclude]
+ const validLayers = layers.filter((l) => map.getLayer(l))
+
+ if (validLayers.length > 0) {
+ const featuresExclude = map.queryRenderedFeatures(
+ evt.point,
+ {
+ layers: validLayers,
+ },
+ )
+ if (featuresExclude && featuresExclude.length > 0) {
+ setPanel(null)
+ return
+ }
}
}
diff --git a/fdm-app/app/routes/farm.$b_id_farm.$calendar.atlas.fields._index.tsx b/fdm-app/app/routes/farm.$b_id_farm.$calendar.atlas.fields._index.tsx
index 73c0be990..607792b46 100644
--- a/fdm-app/app/routes/farm.$b_id_farm.$calendar.atlas.fields._index.tsx
+++ b/fdm-app/app/routes/farm.$b_id_farm.$calendar.atlas.fields._index.tsx
@@ -12,7 +12,10 @@ import { type LoaderFunctionArgs, useLoaderData } from "react-router"
import { ZOOM_LEVEL_FIELDS } from "~/components/blocks/atlas/atlas"
import { Controls } from "~/components/blocks/atlas/atlas-controls"
import { FieldsPanelHover } from "~/components/blocks/atlas/atlas-panels"
-import { FieldsSourceAvailable } from "~/components/blocks/atlas/atlas-sources"
+import {
+ FieldsSourceAvailable,
+ FieldsSourceNotClickable,
+} from "~/components/blocks/atlas/atlas-sources"
import { getFieldsStyle } from "~/components/blocks/atlas/atlas-styles"
import { getViewState } from "~/components/blocks/atlas/atlas-viewstate"
import { getMapboxStyle, getMapboxToken } from "~/integrations/mapbox"
@@ -117,10 +120,10 @@ export default function FarmAtlasFieldsBlock() {
const id = "fieldsSaved"
const fields = loaderData.savedFields
- const _fieldsSavedStyle = getFieldsStyle(id)
+ const fieldsSavedStyle = getFieldsStyle(id)
const fieldsAvailableId = "fieldsAvailable"
const fieldsAvailableStyle = getFieldsStyle(fieldsAvailableId)
- const _fieldsSavedOutlineStyle = getFieldsStyle("fieldsSavedOutline")
+ const fieldsSavedOutlineStyle = getFieldsStyle("fieldsSavedOutline")
const initialViewState = getViewState(fields)
// Create a sessionStorage to store the latest viewstate
@@ -191,6 +194,21 @@ export default function FarmAtlasFieldsBlock() {