Skip to content

Commit e1d314f

Browse files
committed
Do not pass auto grid props to grid
1 parent cb43d7a commit e1d314f

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

packages/ts/react-grid/src/autogrid.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,16 @@ const createColumns = (model: ModelConstructor<any, any>) => {
8282
};
8383

8484
export function AutoGrid<TItem>(props: AutoGridProps<TItem>) {
85+
const { service, model, ...gridProps } = props;
86+
8587
const ref = useRef(null);
8688

8789
useEffect(() => {
8890
const grid = ref.current as any as GridElement<TItem>;
89-
grid.dataProvider = createDataProvider(grid, props.service);
91+
grid.dataProvider = createDataProvider(grid, service);
9092
}, []);
9193

92-
const children = createColumns(props.model);
94+
const children = createColumns(model);
9395

94-
return <Grid {...props} ref={ref} children={children}></Grid>;
96+
return <Grid {...gridProps} ref={ref} children={children}></Grid>;
9597
}

packages/ts/react-grid/test/autogrid.spec.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,9 @@ async function sleep(ms: number) {
3232
);
3333
}
3434
describe('@hilla/react-grid', () => {
35-
// type UseAutoGridSpy = sinon.SinonSpy<Parameters<typeof _useAutoGrid>, ReturnType<typeof _useAutoGrid>>;
36-
// const useAutoGrid = sinon.spy(_useAutoGrid) as typeof _useAutoGrid;
37-
38-
beforeEach(() => {
39-
// (useAutoGrid as UseAutoGridSpy).resetHistory();
40-
});
35+
beforeEach(() => {});
4136

4237
function TestAutoGrid() {
43-
// const autoGrid = useAutoGrid(fakeEndpoint, PersonModel);
4438
return <AutoGrid service={fakeService} model={PersonModel}></AutoGrid>;
4539
}
4640
describe('useAutoGrid', () => {
@@ -69,5 +63,11 @@ describe('@hilla/react-grid', () => {
6963
expect(getBodyCellContent(grid, 1, 0).innerText).to.equal('Jane');
7064
expect(getBodyCellContent(grid, 1, 1).innerText).to.equal('Love');
7165
});
66+
it('does not pass its own parameters to the underlying grid', async () => {
67+
const result = render(<TestAutoGrid />);
68+
const grid: GridElement = result.container.querySelector('vaadin-grid')!;
69+
expect(grid.getAttribute("model")).to.be.null;
70+
expect(grid.getAttribute("service")).to.be.null;
71+
});
7272
});
7373
});

0 commit comments

Comments
 (0)