Skip to content

Table support missing in Collection Primitive #3166

Open
@reesscot

Description

@reesscot

Before creating a new issue, please confirm:

On which framework/platform are you having an issue?

React

Which UI component?

Other

How is your app built?

NA

What browsers are you seeing the problem on?

No response

Please describe your bug.

The Collection component exports table type which is currently not implemented.

https://github.com/aws-amplify/amplify-ui/blob/main/packages/react/src/primitives/types/collection.ts#L6

const collection =
type === 'list' ? (
<ListCollection
className={ComponentClassNames.CollectionItems}
items={items}
{...rest}
/>
) : type === 'grid' ? (
<GridCollection
className={ComponentClassNames.CollectionItems}
items={items}
{...rest}
/>
) : null;

What's the expected behaviour?

type="table" should render a TableRow

Help us reproduce the bug!

This will render null even if users is populated with an array.

<Table highlightOnHover={true} size="small" variation="striped">
      <TableHead>
        <TableCell as="th">Id</TableCell>
        <TableCell as="th">First Name</TableCell>
        <TableCell as="th">Last Name</TableCell>
        <TableCell as="th">Team</TableCell>
      </TableHead>
      <TableBody>
        <Collection items={users} type="table">
          {(item, index) => (
            <TableRow>
              <TableCell>{item.id}</TableCell>
              <TableCell>{item.firstName}</TableCell>
              <TableCell>{item.lastName}</TableCell>
              <TableCell>{item.teamId}</TableCell>
            </TableRow>
          )}
        </Collection>
      </TableBody>
    </Table>

Code Snippet

// Put your code below this line.

Additional information and screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    PrimitiveAn issue or a feature-request for one or more UI PrimitivebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions