Skip to main content

Breaking: Table no longer draws its own card frame

If your app renders Table from @trackunit/react-table, upgrading to 4.0.0 changes how it looks at runtime, with no compile error. Table no longer renders a Card: it loses its border, radius and shadow, and a table inside a flex or grid cell grows to fit all of its rows instead of scrolling. To keep the old look, wrap each Table in <Card scrollableContent> from @trackunit/react-components.

The migration @trackunit/react-table:v4-0-0-wrap-table-in-card does this for you. Run it with the usual upgrade commands, described in Maintaining Your Application:

npx nx g @trackunit/migrations:migrate
npx nx g @trackunit/migrations:run-migrations

What the migration changes​

It wraps each Table imported from @trackunit/react-table in <Card scrollableContent>, adds Card to your @trackunit/react-components import, and moves className, data-testid, key, ref and style from the Table to the Card. Everything else stays on the Table:

// before
<Table {...table} className="h-full" data-testid="assets-table" headerLeftActions={<span />} />

// after
<Card className="h-full" data-testid="assets-table" scrollableContent>
<Table {...table} headerLeftActions={<span />} />
</Card>

scrollableContent keeps the Card inside its flex or grid cell, so the rows scroll inside it. Tables already inside <Card scrollableContent> are left alone, so running the migration again changes nothing.

What it can't handle​

The migration prints each of these with its file and line, and leaves the code for you to fix by hand:

  • Card already names something else in the file: the whole file is skipped.
  • A spread on the Table that could carry className or data-testid, such as {...rest}: the Table is wrapped, but those props would now land on the inner table instead of the Card.
  • Table used through a namespace import (<RT.Table>) or passed on as a value: not changed.
  • A Table that was already inside a Card: it gets an inner Card too, which keeps the double frame it had before. Remove one of them if you want.

The migration is recorded in trackunit-migrations.json even when it printed warnings, so fix those places by hand rather than running it again.

Why it changed​

Table always drew its own card, so it couldn't be used edge to edge, and a table placed inside another card got two frames. The code that renders the table now decides the frame. To render a table without one, give it a parent with a bounded height, such as <div className="h-[400px]">.

See the Table and Card docs for both layouts.