fix(managers): key the row-layout primary cell + measured rowEst
Self-review follow-ups: the `rows` layout mapped the primary column without a React key (single-element today, but a warning waiting to happen); wrap it in a keyed Fragment. Also replace the guessed card/row rowEst with browser-measured values (176 / 62) so the scrollbar doesn't jump on first scroll.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { Fragment } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { type Column } from "./DataTable";
|
||||
import VirtualGrid from "./VirtualGrid";
|
||||
@@ -68,7 +69,11 @@ export default function ChannelLayoutGrid<T>({
|
||||
|
||||
const renderRow = (row: T) => (
|
||||
<div className={`glass-card rounded-xl p-3 flex items-center gap-4 ${rowClassName?.(row) ?? ""}`}>
|
||||
<div className="shrink-0 font-medium">{primary.map((col) => col.render(row))}</div>
|
||||
<div className="shrink-0 font-medium">
|
||||
{primary.map((col) => (
|
||||
<Fragment key={col.key}>{col.render(row)}</Fragment>
|
||||
))}
|
||||
</div>
|
||||
{metaFlow(row)}
|
||||
{actions && <div className="ml-auto shrink-0">{actions.render(row)}</div>}
|
||||
</div>
|
||||
|
||||
@@ -19,9 +19,11 @@ export interface ChannelLayoutSpec {
|
||||
rowEst: number;
|
||||
}
|
||||
|
||||
// rowEst measured in the browser (cards ~176 at 3 columns, the one-line row ~62) — not guessed; a
|
||||
// bad estimate makes the scrollbar jump as you first scroll in.
|
||||
export const CHANNEL_LAYOUT_SPEC: Record<Exclude<ChannelLayout, "table">, ChannelLayoutSpec> = {
|
||||
cards: { minCol: 300, maxCol: null, rowEst: 210 },
|
||||
rows: { minCol: null, maxCol: 1100, rowEst: 88 },
|
||||
cards: { minCol: 300, maxCol: null, rowEst: 176 },
|
||||
rows: { minCol: null, maxCol: 1100, rowEst: 62 },
|
||||
};
|
||||
|
||||
/** Coerce a stored value to a layout; anything unknown (corrupt, a rolled-back future layout) falls
|
||||
|
||||
Reference in New Issue
Block a user