Skip to content

Commit

Permalink
fix: mark headerRenderer as unsupported for GridSortColumn (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan authored Dec 7, 2023
1 parent 4be5956 commit 6d0b03b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
14 changes: 4 additions & 10 deletions src/GridSortColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,27 @@ import { useSimpleRenderer } from './renderers/useSimpleRenderer.js';

export * from './generated/GridSortColumn.js';

/*
* The `headerRenderer` is not allowed for `vaadin-grid-sort-column`.
*/
export type GridSortColumnProps<TItem> = Partial<
Omit<_GridSortColumnProps<TItem>, 'children' | 'footerRenderer' | 'headerRenderer' | 'renderer'>
> &
Readonly<{
children?: ComponentType<GridBodyReactRendererProps<TItem>> | null;
footerRenderer?: ComponentType<GridEdgeReactRendererProps<TItem>> | null;
headerRenderer?: ComponentType<GridEdgeReactRendererProps<TItem>> | null;
renderer?: ComponentType<GridBodyReactRendererProps<TItem>> | null;
}>;

function GridSortColumn<TItem = GridDefaultItem>(
props: GridSortColumnProps<TItem>,
ref: ForwardedRef<GridSortColumnElement<TItem>>,
): ReactElement | null {
const [headerPortals, headerRenderer] = useSimpleRenderer(props.headerRenderer);
const [footerPortals, footerRenderer] = useSimpleRenderer(props.footerRenderer);
const [bodyPortals, bodyRenderer] = useModelRenderer(props.renderer ?? props.children);

return (
<_GridSortColumn<TItem>
{...props}
footerRenderer={footerRenderer}
headerRenderer={headerRenderer}
ref={ref}
renderer={bodyRenderer}
>
{headerPortals}
<_GridSortColumn<TItem> {...props} footerRenderer={footerRenderer} ref={ref} renderer={bodyRenderer}>
{footerPortals}
{bodyPortals}
</_GridSortColumn>
Expand Down
4 changes: 1 addition & 3 deletions test/Grid.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ describe('Grid', () => {
it('should render correctly', async () => {
render(
<Grid<Item> items={items}>
<GridSortColumn<Item> headerRenderer={DefaultHeaderRenderer} footerRenderer={DefaultFooterRenderer}>
{DefaultBodyRenderer}
</GridSortColumn>
<GridSortColumn<Item> footerRenderer={DefaultFooterRenderer}>{DefaultBodyRenderer}</GridSortColumn>
</Grid>,
);

Expand Down

0 comments on commit 6d0b03b

Please sign in to comment.