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.

Fix: hide pagination when a table has no rows (#14631)

Damian Legawiec38207ceca55a
diff --git a/.changeset/hide-empty-pagination.md b/.changeset/hide-empty-pagination.md
new file mode 100644
index 0000000000..6ea900abd9
--- /dev/null
+++ b/.changeset/hide-empty-pagination.md
@@ -0,0 +1,5 @@
+---
+"@spree/dashboard-ui": patch
+---
+
+Hide the pagination footer when a list has no rows, so empty tables no longer show "0–0 of 0" or a rows-per-page control.
diff --git a/packages/dashboard-ui/src/ui/pagination.tsx b/packages/dashboard-ui/src/ui/pagination.tsx
index 83db4b66d5..c03f49fe79 100644
--- a/packages/dashboard-ui/src/ui/pagination.tsx
+++ b/packages/dashboard-ui/src/ui/pagination.tsx
@@ -33,8 +33,10 @@ export function Pagination({
pageSizeOptions = [10, 20, 25, 30, 50],
}: PaginationProps) {
const { t } = useTranslation()
+ const showPageSize = Boolean(onPageSizeChange) && meta.count > 0
+ const showPageNav = meta.pages > 1
- if (meta.pages <= 1 && !onPageSizeChange) return null
+ if (!showPageSize && !showPageNav) return null
return (
<div className="flex items-center justify-between ps-2 py-2">
@@ -46,14 +48,14 @@ export function Pagination({
})}
</div>
<div className="flex items-center gap-2 sm:gap-6">
- {onPageSizeChange && (
+ {showPageSize && (
<div className="hidden items-center gap-2 sm:flex">
<span className="text-sm text-muted-foreground">
{t('admin.components.pagination.rows_per_page')}
</span>
<Select
value={`${meta.limit}`}
- onValueChange={(value) => onPageSizeChange(Number(value))}
+ onValueChange={(value) => onPageSizeChange?.(Number(value))}
>
<SelectTrigger className="h-8 w-[70px]">
<SelectValue />
@@ -68,7 +70,7 @@ export function Pagination({
</Select>
</div>
)}
- {meta.pages > 1 && (
+ {showPageNav && (
<>
<span className="hidden whitespace-nowrap text-sm text-muted-foreground sm:inline">
{t('admin.common.page_of', { page: meta.page, total: meta.pages })}
diff --git a/packages/dashboard/e2e/webhooks.spec.ts b/packages/dashboard/e2e/webhooks.spec.ts
index af6a13d339..b2869610b4 100644
--- a/packages/dashboard/e2e/webhooks.spec.ts
+++ b/packages/dashboard/e2e/webhooks.spec.ts
@@ -35,6 +35,10 @@ test.describe('webhooks', () => {
test('lists webhook endpoints', async ({ page }) => {
const creds = await login(page)
await gotoIndex(page, WEBHOOKS_PATH(creds.store_id), CTA)
+ await expect(page.getByText(/0[–-]0 of 0/)).toHaveCount(0)
+ if (await page.getByText(/no webhook endpoints yet/i).isVisible()) {
+ await expect(page.getByText(/rows per page/i)).toHaveCount(0)
+ }
})
test('creates an endpoint, reveals the secret, and navigates to its detail page', async ({