Small preview fix when "All" option is checked

This commit is contained in:
grafakus
2025-11-18 14:58:28 +01:00
parent 5b685373aa
commit 2d17de2395
@@ -28,15 +28,15 @@ VariableValuesPreview.displayName = 'VariableValuesPreview';
function VariableValuesWithPropsPreview({ options }: { options: VariableValueOption[] }) {
const styles = useStyles2(getStyles);
const data = options.map((o) => ({ label: String(o.label), value: String(o.value), ...o.properties }));
const columns = Object.keys(data[0]).map((id) => ({ id, header: id, sortType: 'alphanumeric' as const }));
// the first item in data may be the "All" option which does not have any extra properties, so we try the 2nd item to determine the column names
const columns = Object.keys(data[1] || data[0]).map((id) => ({ id, header: id, sortType: 'alphanumeric' as const }));
return (
<div className={styles.previewContainer} style={{ gap: '8px' }}>
<Text variant="bodySmall" weight="medium">
<Trans i18nKey="dashboard-scene.variable-values-preview.preview-of-values">Preview of values</Trans>
</Text>
{/* TODO: pageSize=20 */}
<InteractiveTable columns={columns} data={data} getRowId={(r) => String(r.value)} pageSize={2} />
<InteractiveTable columns={columns} data={data} getRowId={(r) => String(r.value)} pageSize={10} />
</div>
);
}