diff --git a/frontend/src/components/ui/collapsible.tsx b/frontend/src/components/ui/collapsible.tsx
index 9605c4e4..1a81b4de 100644
--- a/frontend/src/components/ui/collapsible.tsx
+++ b/frontend/src/components/ui/collapsible.tsx
@@ -1,9 +1,28 @@
+import * as React from 'react';
+
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
+import { cn } from '@/lib/classnames';
+
const Collapsible = CollapsiblePrimitive.Root;
const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger;
-const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent;
+const CollapsibleContent = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, children, ...props }, ref) => (
+
+ {children}
+
+));
+CollapsibleContent.displayName = CollapsiblePrimitive.Content.displayName;
export { Collapsible, CollapsibleTrigger, CollapsibleContent };
diff --git a/frontend/src/containers/map/content/map/layers-toolbox/layers-list/index.tsx b/frontend/src/containers/map/content/map/layers-toolbox/layers-list/index.tsx
index e84b9643..082f04d4 100644
--- a/frontend/src/containers/map/content/map/layers-toolbox/layers-list/index.tsx
+++ b/frontend/src/containers/map/content/map/layers-toolbox/layers-list/index.tsx
@@ -20,7 +20,7 @@ const TABS_ICONS_CLASSES = 'w-5 h-5 -translate-y-[2px]';
const LayersDropdown = (): JSX.Element => {
const [activeLayers, setMapLayers] = useSyncMapLayers();
- const [, setLayerSettings] = useSyncMapLayerSettings();
+ const [layerSettings, setLayerSettings] = useSyncMapLayerSettings();
const [{ labels }, setMapSettings] = useSyncMapSettings();
const layersQuery = useGetLayers(
@@ -45,7 +45,19 @@ const LayersDropdown = (): JSX.Element => {
: activeLayers.filter((_layerId) => _layerId !== Number(layerId))
);
+ // If we don't have layerSettings entries, the view is in its default state; we wish to
+ // show all legend accordion items expanded by default.
+ const initialSettings = (() => {
+ const layerSettingsKeys = Object.keys(layerSettings);
+ if (layerSettingsKeys.length) return {};
+ return Object.assign(
+ {},
+ ...activeLayers.map((layerId) => ({ [layerId]: { expanded: true } }))
+ );
+ })();
+
setLayerSettings((prev) => ({
+ ...initialSettings,
...prev,
[layerId]: {
...prev[layerId],
@@ -53,7 +65,7 @@ const LayersDropdown = (): JSX.Element => {
},
}));
},
- [activeLayers, setLayerSettings, setMapLayers]
+ [activeLayers, layerSettings, setLayerSettings, setMapLayers]
);
const handleLabelsChange = useCallback(
@@ -71,8 +83,10 @@ const LayersDropdown = (): JSX.Element => {
Data Layers
-
-
+
+
@@ -109,11 +123,13 @@ const LayersDropdown = (): JSX.Element => {
className={`${COLLAPSIBLE_TRIGGER_CLASSES} pb-0 data-[state=open]:pb-2`}
>
basemap Layers
-
-
+
+
-
+
-
)}
{layersQuery.data?.length > 0 && (
- {
- return layerSettings[layerId].expanded ? layerId.toString() : null;
- })}
- onValueChange={onToggleAccordion}
- >
+
{layersQuery.data?.map(({ id, attributes: { title, legend_config } }, index) => {
const isFirst = index === 0;
const isLast = index + 1 === layersQuery.data.length;
diff --git a/frontend/tailwind.config.js b/frontend/tailwind.config.js
index 46e3c7e2..0788b62b 100644
--- a/frontend/tailwind.config.js
+++ b/frontend/tailwind.config.js
@@ -45,10 +45,20 @@ module.exports = {
from: { height: 'var(--radix-accordion-content-height)' },
to: { height: 0 },
},
+ 'collapsible-down': {
+ from: { height: 0 },
+ to: { height: 'var(--radix-collapsible-content-height)' },
+ },
+ 'collapsible-up': {
+ from: { height: 'var(--radix-collapsible-content-height)' },
+ to: { height: 0 },
+ },
},
animation: {
'accordion-down': 'accordion-down 0.2s ease-out',
'accordion-up': 'accordion-up 0.2s ease-out',
+ 'collapsible-down': 'collapsible-down 0.2s ease-out',
+ 'collapsible-up': 'collapsible-up 0.2s ease-out',
},
},
},