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: Handling no columns #1170

Merged
merged 1 commit into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
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
17 changes: 15 additions & 2 deletions packages/iris-grid/src/IrisGrid.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class MockPath2D {
addPath = jest.fn();
}

window.Path2D = MockPath2D;
window.Path2D = (MockPath2D as unknown) as new () => Path2D;

const VIEW_SIZE = 5000;

Expand Down Expand Up @@ -61,7 +61,8 @@ function makeComponent(
createNodeMock,
}
);
return testRenderer.getInstance();
return testRenderer.getInstance() as TestRenderer.ReactTestInstance &
IrisGrid;
}

function keyDown(key, component, extraArgs?) {
Expand Down Expand Up @@ -193,3 +194,15 @@ it('handles undefined operator, should default to eq', () => {
'any'
);
});

it('should set gotoValueSelectedColumnName to empty string if no columns are given', () => {
const component = makeComponent(
IrisGridTestUtils.makeModel(
IrisGridTestUtils.makeTable({
columns: [],
})
)
);

expect(component.state.gotoValueSelectedColumnName).toEqual('');
});
2 changes: 1 addition & 1 deletion packages/iris-grid/src/IrisGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ export class IrisGrid extends Component<IrisGridProps, IrisGridState> {
gotoRowError: '',
gotoValueError: '',

gotoValueSelectedColumnName: model.columns[0].name,
gotoValueSelectedColumnName: model.columns[0]?.name ?? '',
gotoValueSelectedFilter: FilterType.eq,
gotoValue: '',
columnHeaderGroups: columnHeaderGroups ?? model.initialColumnHeaderGroups,
Expand Down