From f52327472b8c9d76a90072b27990347c895ed76d Mon Sep 17 00:00:00 2001
From: Piotr Gawron <p.gawron@atcomp.pl>
Date: Fri, 4 Oct 2024 12:36:58 +0200
Subject: [PATCH] by default use first option when exporting to image

---
 .../ImageFormat/ImageFormat.component.tsx           | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/components/Map/Drawer/ExportDrawer/ExportCompound/ImageFormat/ImageFormat.component.tsx b/src/components/Map/Drawer/ExportDrawer/ExportCompound/ImageFormat/ImageFormat.component.tsx
index 48ab8817..3b735d20 100644
--- a/src/components/Map/Drawer/ExportDrawer/ExportCompound/ImageFormat/ImageFormat.component.tsx
+++ b/src/components/Map/Drawer/ExportDrawer/ExportCompound/ImageFormat/ImageFormat.component.tsx
@@ -4,7 +4,8 @@ import {
   loadingConfigurationMainSelector,
 } from '@/redux/configuration/configuration.selectors';
 import { useAppSelector } from '@/redux/hooks/useAppSelector';
-import { useContext } from 'react';
+import { useContext, useState } from 'react';
+import { CheckboxItem } from '@/components/Map/Drawer/ExportDrawer/CheckboxFilter/CheckboxFilter.types';
 import { CheckboxFilter } from '../../CheckboxFilter';
 import { CollapsibleSection } from '../../CollapsibleSection';
 import { ExportContext } from '../ExportCompound.context';
@@ -23,6 +24,16 @@ export const ImageFormat = (): React.ReactNode => {
       label: name,
     }));
 
+  const options = useState<CheckboxItem[]>(mappedElementAnnotations);
+  if (
+    !isPending &&
+    currentImageFormats.length === ZERO &&
+    options.length > ZERO &&
+    options[ZERO].length > ZERO
+  ) {
+    setImageFormats([options[ZERO][ZERO]]);
+  }
+
   return (
     <CollapsibleSection title="Image format">
       {isPending && <p>Loading...</p>}
-- 
GitLab