mirror of
https://github.com/grafana/grafana.git
synced 2024-11-30 12:44:10 -06:00
Old Table: Table is not rendering when col property is undefined (#44129)
This commit is contained in:
parent
24efb42f19
commit
58b8d84085
@ -55,6 +55,34 @@ describe('when sorting table asc', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('when sorting table with cols being undefined', () => {
|
||||
let table: TableModel;
|
||||
const panel = {
|
||||
sort: { cols: undefined, desc: false },
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
table = new TableModel();
|
||||
// @ts-ignore
|
||||
table.columns = [{}, {}];
|
||||
table.rows = [
|
||||
[100, 11],
|
||||
[105, 15],
|
||||
[103, 10],
|
||||
];
|
||||
// This is needed because after 8.3 cols can be undefined
|
||||
// https://github.com/grafana/grafana/issues/44127
|
||||
//@ts-ignore
|
||||
table.sort(panel.sort);
|
||||
});
|
||||
|
||||
it('should return the original table without sorting', () => {
|
||||
expect(table.rows[0][1]).toBe(11);
|
||||
expect(table.rows[1][1]).toBe(15);
|
||||
expect(table.rows[2][1]).toBe(10);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when sorting with nulls', () => {
|
||||
let table: TableModel;
|
||||
let values;
|
||||
|
@ -41,7 +41,8 @@ export default class TableModel implements TableData {
|
||||
}
|
||||
|
||||
sort(options: { col: number; desc: boolean }) {
|
||||
if (options.col === null || this.columns.length <= options.col) {
|
||||
// Since 8.3.0 col property can be also undefined, https://github.com/grafana/grafana/issues/44127
|
||||
if (options.col === null || options.col === undefined || this.columns.length <= options.col) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user