Skip to content

Commit

Permalink
Fix hide of Click options layers (#660)
Browse files Browse the repository at this point in the history
* Fix hide of Click options layers

* add graphic layer after clear selection option
  • Loading branch information
cmanciero authored Mar 26, 2024
1 parent 0caa61d commit 2f5a43a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ function AnalyzeAreasCardComponent({
id={option.slug}
option={{ ...option, name: option.label }}
checked={selectedOption?.slug === option.slug}
onChange={() => handleOptionSelection(option)}
onChange={() => {
if (selectedOption?.slug !== option.slug) {
handleOptionSelection(option);
}
}}
theme={radioTheme}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
COMMUNITY_AREAS_VECTOR_TILE_LAYER,
WDPA_OECM_FEATURE_LAYER,
HALF_EARTH_FUTURE_TILE_LAYER,
GRAPHIC_LAYER,
} from 'constants/layers-slugs';
import { LAYERS_CATEGORIES } from 'constants/mol-layers-configs';

Expand Down Expand Up @@ -223,7 +224,8 @@ function AnalyzeAreasContainer(props) {
layersToToggle.push({ layerId: formerSelectedSlug });
if (
newSelectedOption !== CLEAR_SELECTIONS &&
formerSelectedSlug !== undefined
(formerSelectedSlug !== undefined ||
formerSelectedSlug !== CLEAR_SELECTIONS)
) {
layersToToggle.push({
layerId: newSelectedOption,
Expand All @@ -235,6 +237,12 @@ function AnalyzeAreasContainer(props) {
}));
}

if (formerSelectedSlug === CLEAR_SELECTIONS) {
layersToToggle.push({
layerId: GRAPHIC_LAYER,
});
}

if (protectedAreasSelected) {
const additionalProtectedAreasLayers = [
PROTECTED_AREAS_VECTOR_TILE_LAYER,
Expand All @@ -254,6 +262,7 @@ function AnalyzeAreasContainer(props) {
};

const layersToToggle = getLayersToToggle();

const categories = layersToToggle.reduce((acc, layer) => {
acc[layer.layerId] = layer.category;
return acc;
Expand All @@ -275,10 +284,6 @@ function AnalyzeAreasContainer(props) {
setSketchWidgetMode('create'); // Maybe it was in edit mode
handleSketchToolDestroy();
}

if (selectedTab === 'click') {
handleLayerToggle(precalculatedAOIOptions[0]);
}
};

const handleOptionSelection = (option) => {
Expand Down

0 comments on commit 2f5a43a

Please sign in to comment.