From d3e525c7707475d0053a04acb6f0fda1f81cec2b Mon Sep 17 00:00:00 2001 From: dgboss Date: Tue, 5 Mar 2024 16:01:42 -0800 Subject: [PATCH] Fix jumping legend (#3450) --- .../features/fba/components/map/Legend.tsx | 85 +++++++++++-------- 1 file changed, 48 insertions(+), 37 deletions(-) diff --git a/web/src/features/fba/components/map/Legend.tsx b/web/src/features/fba/components/map/Legend.tsx index 23ffe9193..07638511e 100644 --- a/web/src/features/fba/components/map/Legend.tsx +++ b/web/src/features/fba/components/map/Legend.tsx @@ -39,48 +39,58 @@ interface LegendItemProps { onChange: (event: React.ChangeEvent, checked: boolean) => void subItems?: SubItem[] description?: string | null + renderEmptyDescription?: boolean } -const LegendItem: React.FC = ({ label, checked, onChange, subItems, description }) => ( -
- - - - - - - - {label} - +const LegendItem: React.FC = ({ + label, + checked, + onChange, + subItems, + description, + renderEmptyDescription = false +}) => { + return ( +
+ + + + + + + + {label} + + - - - - - {description} - + + + + {description ?? (renderEmptyDescription &&  )} + + - - {subItems && ( - - {subItems.map(subItem => ( - - - - - {subItem.label} - - ))} - - )} - -
-) + {subItems && ( + + {subItems.map(subItem => ( + + + + + {subItem.label} + + ))} + + )} +
+
+ ) +} interface LegendProps { onToggleLayer: (layerName: string, isVisible: boolean) => void @@ -143,6 +153,7 @@ const Legend = ({ checked={showSnow} onChange={() => handleLayerChange('snowVector', showSnow, setShowSnow)} description={snowDescription} + renderEmptyDescription={true} > )