Hey all I have run in to a wired bug today and try...
# gooddata-ui
g
Hey all I have run in to a wired bug today and trying to figure out if it is an issue with my React FE or the GD backend. I have embedded insight reports that work fine when I initially open them and continue to work fine as I filter them or sort them by the first column on the report by ascending. But as soon as I try and sort by descending or using the second column or any preceding column, I run into the issue where I get this loading phase that it never gets out of. I have found this to be true for different workspaces, browsers and reports. It doesn't appear to be a compute issue for my snowflake backend because the analyzer works just fine when I login into GD directly and when accessing it through an iframe. My issue seems to be limited to the SDK insights.
i
Hello Grant, Thanks for the question, I am looking into it now.
Hello again Grant, 1. May I ask which version of SDK you are using? 2. Also could you please provide a code that we can use to reproduce the issue on our end? 3. Lastly, if you check console while sorting, do you see any errors? Meanwhile, Could you please try adding or checking if this line exists the dashboard config
enableChartsSorting: true
in
Copy code
const GoodDataDashboardConfig = {
  isReadOnly: true,
  mapboxToken,
  menuButtonItemsVisibility: {
    pdfExportButton: false,
  },
  settings: {
    enableDescriptions: true,
    enableDrilledInsightExport: false,
    enableChartsSorting: true,
  },
};
Thank you
g
Thanks for the response, 1. "@kapa.ai/api-client-tiger": "^10.20.0", "@kapa.ai/sdk-backend-tiger": "^10.20.0", "@kapa.ai/sdk-ui-all": "^10.20.0", "@kapa.ai/sdk-ui-dashboard": "^10.22.0", "@kapa.ai/sdk-ui-geo": "^10.22.0",
Copy code
import { Box, CssBaseline, ListItem, List, Divider, Tooltip } from '@mui/material';
import { useTitle } from 'core/hooks/title';
import { useTranslation } from 'react-i18next';
import { useCallback, useState } from 'react';
import {
	IAttribute,
	IAttributeFilter,
	IDateFilter,
	InsightView,
	newNegativeAttributeFilter,
	ObjRef,
} from '@gooddata/sdk-ui-all';
import * as idRef from 'gooddata/catalog.ts';
import StyledDrawer from 'components/navigation/StyledDrawer';
import StyledHeaderListItemText from 'components/navigation/StyledHeaderListItemText';
import StyledListItem from 'components/navigation/StyledListItem';
import StyledListItemButton from 'components/navigation/StyledListItemButton';
import StyledFilterBar from 'core/components/filtering/StyledFilterBar';
import { AttributeFilterReports } from 'core/components/filtering/AttributeFilter';
import { DateFilterReports } from 'core/components/filtering/DateFilter';
import { PredefinedDateOptionKey } from 'core/components/filtering/dateFilterConstants';
import TruncatedListItemText from 'components/navigation/TruncatedListItemText';

export default function Basic() {
	const { t } = useTranslation('reports');

	useTitle(`${t('basic.title')} - ${t('core:title')}`);

	const insight: [string, string, [ObjRef | null, string, PredefinedDateOptionKey, string], IAttribute[]][] = [
		[
			'Inspection Summary',
			idRef.Insights.InspectionSummaryBasicReport,
			[
				idRef.DateDatasets.InspectionStartDatetimeInspectInspection,
				'Inspection Start Datetime (Inspect Inspection)',
				'LAST_7_DAYS',
				idRef.Insights.InspectionSummaryBasicReport,
			],
			[
				idRef.InspectorCodeFullNameInspectInspector,
				idRef.GroupNameInspectUserGroup,
				idRef.HasOOSDriverInspectInspection,
				idRef.HasOOSVehicleInspectInspection,
				idRef.HazmatTypeCodeFullInspectInspection,
				idRef.InspectionLevelInspectInspection,
				idRef.LocationCodeInspectInspection,
			],
		],
		[
			'Citations Issued',
			idRef.Insights.CitationsIssuedBasicReport,
			[
				idRef.DateDatasets.InspectionStartDatetimeInspectInspection,
				'Inspection Start Datetime (Inspect Inspection)',
				'LAST_7_DAYS',
				idRef.Insights.CitationsIssuedBasicReport,
			],
			[idRef.InspectorCodeFullNameInspectInspector, idRef.LocationCodeInspectInspection],
		],
		[
			'PRISM New Entrant Vehicle',
			idRef.Insights.PRISMNewEntrantVehiclesBasicReport,
			[
				idRef.DateDatasets.NewEntrantEntryDatePRISMVehicleEntered,
				'New Entrant Entry Date (PRISM Vehicle Entered)',
				'LAST_7_DAYS',
				idRef.Insights.PRISMNewEntrantVehiclesBasicReport,
			],
			[idRef.VehicleLicensePlateStateCodePRISMVehicleEntered, idRef.USDOTPRISMVehicleEntered],
		],
		// Add more insights as needed
	];

	const [insightId, setInsightId] = useState(insight[0][1]);

	const selectedInsight = insight.find(([, id]) => id === insightId);
	const selectedDateDataset = selectedInsight ? selectedInsight[2] : null;
	const customFilterName = selectedDateDataset ? selectedDateDataset[1] : '';
	const selectedAttributeFilter = selectedInsight ? selectedInsight[3] : [];

	const [attributeFilters, setAttributeFilters] = useState<IAttributeFilter[]>(
		selectedAttributeFilter.map((ref) => newNegativeAttributeFilter(ref, [])),
	);

	const handleInsightChange = (id: string) => {
		setInsightId(id);
		setInsightId(id);
		const found = insight.find(([, i]) => i === id);
		const attrRefs = found ? found[3] : [];
		setAttributeFilters(attrRefs.map((ref) => newNegativeAttributeFilter(ref, [])));
		setDateFilter(null);
	};

	const [dateFilter, setDateFilter] = useState<IDateFilter | null>(null);

	const handleFilterApply = (updatedFilter: IAttributeFilter, index: number) => {
		setAttributeFilters((prevFilters) => {
			const newFilters = [...prevFilters];
			newFilters[index] = updatedFilter;
			return newFilters;
		});
	};

	const handleDateFilterApply = useCallback((selectedFilterOption: IDateFilter) => {
		setDateFilter({
			...selectedFilterOption,
		});
	}, []);

	const filters = [...attributeFilters, ...(dateFilter ? [dateFilter] : [])];

	return (
		<Box sx={{ display: 'flex', height: '100%' }}>
			<CssBaseline />
			<StyledDrawer variant="permanent" anchor="left">
				<List>
					<ListItem>
						<StyledHeaderListItemText primary="REPORTS" />
					</ListItem>
				</List>
				<Divider />
				<List>
					{insight.map(([text, id]) => (
						<Tooltip key={id} title={text} placement="right" arrow>
							<StyledListItem selected={insightId === id}>
								<StyledListItemButton onClick={() => handleInsightChange(id)}>
									<TruncatedListItemText primary={text} />
								</StyledListItemButton>
							</StyledListItem>
						</Tooltip>
					))}
				</List>
			</StyledDrawer>
			<Box sx={{ flexGrow: 1, display: 'flex', flexDirection: 'column' }}>
				<StyledFilterBar>
					{selectedDateDataset && selectedDateDataset[0] && (
						<DateFilterReports
							dataSet={selectedDateDataset[0]}
							customFilterName={customFilterName}
							dateRangeOption={selectedDateDataset[2]}
							onDateFilterChange={handleDateFilterApply}
							reportId={selectedDateDataset[3]}
						/>
					)}
					<AttributeFilterReports filters={attributeFilters} onApply={handleFilterApply} />
				</StyledFilterBar>
				<Box sx={{ flexGrow: 1, overflow: 'auto' }}>
					<InsightView insight={insightId} filters={filters} />
				</Box>
			</Box>
		</Box>
	);
}
k
Thank you for sharing your package versions: - `@gooddata/api-client-tiger`: ^10.20.0 - `@gooddata/sdk-backend-tiger`: ^10.20.0 - `@gooddata/sdk-ui-all`: ^10.20.0 - `@gooddata/sdk-ui-dashboard`: ^10.22.0 - `@gooddata/sdk-ui-geo`: ^10.22.0 If you are asking whether these versions are compatible: Based on the changelog, there are no breaking changes or incompatibilities noted between 10.20.0 and 10.22.0 for these packages. The 10.20.0 release is a "version update only" with no functional changes, and 10.22.0 introduces new features and improvements but does not mention breaking changes that would affect compatibility with 10.20.0 versions of the other packages. It is common and supported to use minor version differences within the same major version for GoodData UI SDK packages, as they are designed to be compatible within a major version range [Changelog 10.20.0](https://github.com/gooddata/gooddata-ui-sdk/blob/master/libs/sdk-ui-all/CHANGELOG.md), [Changelog 10.22.0](https://github.com/gooddata/gooddata-ui-sdk/blob/master/libs/sdk-ui-all/CHANGELOG.md). If you are experiencing issues, please provide more details about the problem, as the knowledge sources do not indicate any incompatibility for the versions you listed. If you are integrating into an existing React app, ensure you have also included the required CSS imports for each UI package you use, as described in the integration guide [Integrate CN and Cloud into an Existing Application](https://www.gooddata.com/docs/gooddata-ui/latest/learn/integrate_and_authenticate/cn_and_cloud_integration/). If you need further clarification or have a specific error, please provide more context.
g
3. I get these errors in the console
k
A message from kapa.ai
Your code structure and the use of GoodData UI SDK components look correct for rendering insights with filters in a React application. Based on the package versions you provided: - `@gooddata/api-client-tiger`: ^10.20.0 - `@gooddata/sdk-backend-tiger`: ^10.20.0 - `@gooddata/sdk-ui-all`: ^10.20.0 - `@gooddata/sdk-ui-dashboard`: ^10.22.0 - `@gooddata/sdk-ui-geo`: ^10.22.0 These versions are compatible with each other, as GoodData UI SDK packages are designed to work together within the same major version (10.x). Minor version differences (e.g., 10.20.0 vs 10.22.0) are generally supported and should not cause issues, as confirmed in the documentation and community discussions [Architecture Overview](https://www.gooddata.com/docs/gooddata-ui/latest/architecture/architecture_overview/). A few important reminders and best practices: 1. CSS Imports: Make sure you are importing the required CSS files for all GoodData UI packages you use. For example:
Copy code
js    import "@gooddata/sdk-ui-charts/styles/css/main.css";    import "@gooddata/sdk-ui-pivot/styles/css/main.css";    import "@gooddata/sdk-ui-geo/styles/css/main.css";    import "@gooddata/sdk-ui-ext/styles/css/main.css";    import "@gooddata/sdk-ui-dashboard/styles/css/main.css";    import "@gooddata/sdk-ui-kit/styles/css/main.css";
This is necessary for proper rendering and theming of GoodData components [Integrate CN and Cloud into an Existing Application](https://www.gooddata.com/docs/gooddata-ui/latest/learn/integrate_and_authenticate/cn_and_cloud_integration/). 2. Backend and Workspace Providers: Your code snippet does not show the context providers (
BackendProvider
,
WorkspaceProvider
). These are required to wrap your application or the part of the component tree using GoodData components. Without them, components like
InsightView
will not work and may throw errors about missing backend or workspace context. 3. Catalog References: Ensure that your
idRef
imports (e.g.,
idRef.Insights.InspectionSummaryBasicReport
) are generated using the [catalog-export tool](https://www.gooddata.com/docs/gooddata-ui/latest/learn/visualize_data/export_catalog/), and that they match the objects in your GoodData workspace. 4. React Version: GoodData UI SDK v10.x supports React 18. If you are using React 18+, ensure you are using
createRoot
instead of the deprecated
ReactDOM.render
in your app entry point, as discussed in the community [React 18 migration](https://gooddataconnect.slack.com/archives/C01UR5BGAHY/p1723474223446119?thread_ts=1723474223.446119&amp;cid=C01UR5BGAHY). 5. Error Handling: If you encounter issues such as infinite loading or missing icons, double-check your CSS imports and ensure all dependencies are installed at compatible versions. For Vite or Next.js, you may need to adjust your build config to resolve GoodData packages correctly, as seen in community solutions. Summary: Your approach and code are aligned with GoodData UI SDK best practices, and your package versions are compatible. Just ensure you have the required context providers and CSS imports in place. If you encounter specific errors, please provide the error message for more targeted help. If you need a minimal working example or further troubleshooting, let me know!
y
Hi Grant, Allow me to jump in here. I see that you are currently using an older version of the SDK. Have you tried updating both the SDK and React to a newer version to check if the issue still persists? We recently released React SDK version 11, which introduces support for React 19. Please note that support for React 16 and 17 will eventually be removed, so the recommended approach is to upgrade to a higher version of React along with the SDK. Could you try upgrading and let us know if the issue continues? Please find more information on the release in the documentation here and the latest releases here We’ll be happy to assist further if needed.
g
That fixed the problem thank you
i
I am happy that the issue is fixed by updating the SDK version. Have a nice day.