Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(legend): fix legend in export modal when no footerbar #closes2066 #2128

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Box, Button, Dialog, DialogActions, DialogContent, DialogTitle, Loading
import { exportPNG } from '@/core/utils/utilities';
import { DateMgt } from '@/core/utils/date-mgt';
import { useUIActiveFocusItem, useUIStoreActions } from '@/core/stores/store-interface-and-intial-values/ui-state';
import { useGeoViewMapId } from '@/core/stores/geoview-store';
import { useGeoViewConfig, useGeoViewMapId } from '@/core/stores/geoview-store';
import { useAppGeoviewHTMLElement } from '@/core/stores/store-interface-and-intial-values/app-state';
import { NorthArrowIcon } from '@/core/components/north-arrow/north-arrow-icon';
import { useMapAttribution, useMapNorthArrow, useMapScale } from '@/core/stores/store-interface-and-intial-values/map-state';
Expand Down Expand Up @@ -46,6 +46,7 @@ export default function ExportModal(): JSX.Element {
const textFieldRef = useRef(null) as RefObject<HTMLInputElement>;
const exportTitleRef = useRef(null) as RefObject<HTMLDivElement>;

const geoviewConfig = useGeoViewConfig();
const northArrow = useMapNorthArrow();
const scale = useMapScale();
const mapAttributions = useMapAttribution();
Expand Down Expand Up @@ -117,9 +118,8 @@ export default function ExportModal(): JSX.Element {

// add legend
const legendContainer = document.getElementById(`${mapId}-legendContainer`);
if (legendContainer && legendContainerRef.current) {
if (legendContainer && legendContainerRef.current && Object.keys(geoviewConfig?.footerBar?.tabs ?? {}).length) {
legendContainer.removeAttribute('style');
setIsLegendLoading(true);
// remove hidden attribute from document legend, so that html-to-image can copy the legend container.
const legendTab = document.getElementById(`${mapId}-legend`) as HTMLElement;
const hasHiddenAttr = legendTab?.hasAttribute('hidden') ?? null;
Expand All @@ -137,6 +137,8 @@ export default function ExportModal(): JSX.Element {
.catch((error: Error) => {
logger.logError('Error occured while converting legend to image', error);
});
} else {
setIsLegendLoading(false);
}
}, 10);
}
Expand Down
Loading