Skip to content

Commit

Permalink
fix: mark headerRenderer as unsupported for GridSortColumn
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan committed Dec 6, 2023
1 parent 4be5956 commit e595932
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/GridSortColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,32 @@ 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}
{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 e595932

Please sign in to comment.