Skip to content

Commit

Permalink
Prevent crash when missing location bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
clementprdhomme committed Oct 14, 2024
1 parent c519b74 commit 185477a
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,18 @@ const SidebarDetails: FCWithMessages = () => {
return marine_bounds;
}

if (terrestrial_bounds === undefined || marine_bounds === undefined) {
if (terrestrial_bounds === undefined && marine_bounds === undefined) {
return null;
}

return combineBoundingBoxes(terrestrial_bounds as BBox, marine_bounds as BBox);
return combineBoundingBoxes(
// Falling back to the marine bounds because some locations don't have terrestrial bounds e.g.
// ABJN and Gibraltar
(terrestrial_bounds ?? marine_bounds) as BBox,
// Falling back to the terrestrial bounds because some locations don't have marine bounds e.g.
// any country without coast
(marine_bounds ?? terrestrial_bounds) as BBox
);
}, [locationsData, tab]);

const memberCountries = useMemo(() => {
Expand Down

0 comments on commit 185477a

Please sign in to comment.