TableNG: Fallback to AutoCell when cellType is unmapped (#107920)

pull/107923/head
Paul Marbach 2 weeks ago committed by GitHub
parent 5612edd8b5
commit 9aaaa87bcf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      packages/grafana-ui/src/components/Table/TableNG/Cells/renderers.test.tsx
  2. 2
      packages/grafana-ui/src/components/Table/TableNG/Cells/renderers.tsx

@ -141,6 +141,14 @@ describe('TableNG Cells renderers', () => {
expect(container).toBeInTheDocument();
expect(container.childNodes).toHaveLength(1);
});
it('should return AutoCell when cellOptions is unmapped', () => {
const field = createField(FieldType.string);
const { container } = renderCell(field, { type: 'number' } as unknown as TableCellOptions);
expect(container).toBeInTheDocument();
expect(container.childNodes).toHaveLength(1);
});
});
});

@ -109,7 +109,7 @@ export function getCellRenderer(field: Field, cellOptions: TableCellOptions): Ta
if (cellType === TableCellDisplayMode.Auto) {
return getAutoRendererResult(field);
}
return CELL_RENDERERS[cellType];
return CELL_RENDERERS[cellType] ?? AUTO_RENDERER;
}
/** @internal */

Loading…
Cancel
Save