Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Let a table in a card scroll sideways again

Łukasz Adamczykbd6a2dfd52a1
diff --git a/packages/dashboard-ui/src/ui/data-table.tsx b/packages/dashboard-ui/src/ui/data-table.tsx
index 1f9cb6f593..3fd5b2b670 100644
--- a/packages/dashboard-ui/src/ui/data-table.tsx
+++ b/packages/dashboard-ui/src/ui/data-table.tsx
@@ -33,6 +33,15 @@ interface TableProps extends React.ComponentProps<'table'> {
* own radius.
*/
roundedBottom?: boolean
+ /**
+ * Scrolls sideways at every width, not just on narrow viewports. For a table
+ * in a bounded container — a card, a sheet, a dialog — where the default
+ * `clip` puts the last columns out of reach with no way to get at them: the
+ * container is narrow while the viewport is not, so the breakpoint never
+ * fires. Not for a page's main table, where `overflow-x: auto` computing
+ * `overflow-y` to `auto` would trap a sticky header.
+ */
+ scrollX?: boolean
}
/**
@@ -56,7 +65,14 @@ interface TableProps extends React.ComponentProps<'table'> {
* rounding), and a scroll listener mirrors the body's `scrollLeft` onto the
* pinned table so the header tracks horizontal scrolling.
*/
-function Table({ className, children, stickyHeader = false, roundedBottom, ...props }: TableProps) {
+function Table({
+ className,
+ children,
+ stickyHeader = false,
+ roundedBottom,
+ scrollX = false,
+ ...props
+}: TableProps) {
const scrollRef = useRef<HTMLDivElement | null>(null)
const bodyTableRef = useRef<HTMLTableElement | null>(null)
const pinnedTableRef = useRef<HTMLTableElement | null>(null)
@@ -141,7 +157,10 @@ function Table({ className, children, stickyHeader = false, roundedBottom, ...pr
// sticky header.
<div
className={cn(
- '@container/table-scroll overflow-x-auto md:overflow-x-clip',
+ '@container/table-scroll overflow-x-auto',
+ // The sticky variant's scroller is themed; a scrollbar this one
+ // actually shows should match it.
+ scrollX ? 'themed-scrollbar' : 'md:overflow-x-clip',
wrapperRoundedClasses,
)}
>
diff --git a/packages/dashboard/src/components/spree/stock-history-card.tsx b/packages/dashboard/src/components/spree/stock-history-card.tsx
index 072a7fe72d..b1a261f1fc 100644
--- a/packages/dashboard/src/components/spree/stock-history-card.tsx
+++ b/packages/dashboard/src/components/spree/stock-history-card.tsx
@@ -91,7 +91,7 @@ export function StockHistoryCard({
{/* The pagination bar brings its own top rule and padding, so it
takes the card's bottom curve when it is there — and the last
row takes it when the history fits on one page. */}
- <Table roundedBottom={!paginated}>
+ <Table scrollX roundedBottom={!paginated}>
<TableHeader>
<TableRow>
<TableHead>{t('admin.stock_history.columns.when')}</TableHead>
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId.tsx
index 1e4ced2c3f..45f9b5d1c2 100644
--- a/packages/dashboard/src/routes/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId.tsx
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId.tsx
@@ -198,7 +198,7 @@ function ItemsCard({ purchaseOrder }: { purchaseOrder: PurchaseOrder }) {
) : (
/* Nothing sits below the table on a draft, so its last row carries
the card's own curve; on a receivable order the footer does. */
- <Table roundedBottom={!receivable}>
+ <Table scrollX roundedBottom={!receivable}>
<TableHeader>
<TableRow>
<TableHead>{t('admin.inventory_lines.columns.variant')}</TableHead>
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/transfers/$transferId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/transfers/$transferId.tsx
index d84f47f6a7..467c65a6f1 100644
--- a/packages/dashboard/src/routes/_authenticated/$storeId/products/transfers/$transferId.tsx
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/transfers/$transferId.tsx
@@ -200,7 +200,7 @@ function PlannedItemsCard({ transfer }: { transfer: StockTransfer }) {
{t('admin.stock_transfers.items_empty')}
</p>
) : (
- <Table roundedBottom>
+ <Table scrollX roundedBottom>
<TableHeader>
<TableRow>
<TableHead>{t('admin.inventory_lines.columns.variant')}</TableHead>
@@ -283,7 +283,7 @@ function ReceiveCard({ transfer }: { transfer: StockTransfer }) {
<CardTitle>{t('admin.stock_transfers.receive_title')}</CardTitle>
</CardHeader>
<CardContent className="flex flex-col p-0">
- <Table>
+ <Table scrollX>
<TableHeader>
<TableRow>
<TableHead>{t('admin.inventory_lines.columns.variant')}</TableHead>