diff --git a/app/layout/scenarios/edit/map/legend/hooks/index.ts b/app/layout/scenarios/edit/map/legend/hooks/index.ts index 4fca49f883..59cdfd75a2 100644 --- a/app/layout/scenarios/edit/map/legend/hooks/index.ts +++ b/app/layout/scenarios/edit/map/legend/hooks/index.ts @@ -226,8 +226,13 @@ export const useLockInLegend = () => { const { puTmpIncludedValue, puIncludedValue, layerSettings } = useAppSelector( (state) => state[`/scenarios/${sid}/edit`] ); + + const totalIncludedAreas = [...puIncludedValue, ...puTmpIncludedValue]; + + if (!totalIncludedAreas.length) return null; + return LEGEND_LAYERS['lock-in']({ - puIncludedValue: [...puIncludedValue, ...puTmpIncludedValue], + puIncludedValue: totalIncludedAreas, onChangeVisibility: () => { dispatch( setLayerSettings({ @@ -253,8 +258,12 @@ export const useLockOutLegend = () => { (state) => state[`/scenarios/${sid}/edit`] ); + const totalExcludedAreas = [...puExcludedValue, ...puTmpExcludedValue]; + + if (!totalExcludedAreas.length) return null; + return LEGEND_LAYERS['lock-out']({ - puExcludedValue: [...puExcludedValue, ...puTmpExcludedValue], + puExcludedValue: totalExcludedAreas, onChangeVisibility: () => { dispatch( setLayerSettings({ @@ -279,8 +288,12 @@ export const useLockAvailableLegend = () => { (state) => state[`/scenarios/${sid}/edit`] ); + const totalAvailableAreas = [...puAvailableValue, ...puTmpAvailableValue]; + + if (!totalAvailableAreas.length) return null; + return LEGEND_LAYERS['lock-available']({ - puAvailableValue: [...puAvailableValue, ...puTmpAvailableValue], + puAvailableValue: totalAvailableAreas, onChangeVisibility: () => { dispatch( setLayerSettings({