From 95b39487ed0f3ea25c0c00c107d1fcd919b1d279 Mon Sep 17 00:00:00 2001 From: shui Date: Sun, 12 Apr 2026 08:36:14 +0800 Subject: [PATCH] fix: show page number when totalPages equals 1 in Pagination The range() helper was returning an empty array when start >= end, but it should return a single element when start equals end (i.e., totalPages = 1). This fixes the bug where the current page number was not displayed when there is only one page in the Pagination component. Fixes #1048 --- packages/ui/src/components/Pagination/helpers.test.ts | 7 +++++-- packages/ui/src/components/Pagination/helpers.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/components/Pagination/helpers.test.ts b/packages/ui/src/components/Pagination/helpers.test.ts index d5e33ef088..806fbbf3f9 100644 --- a/packages/ui/src/components/Pagination/helpers.test.ts +++ b/packages/ui/src/components/Pagination/helpers.test.ts @@ -2,9 +2,12 @@ import { describe, expect, it } from "vitest"; import { range } from "./helpers"; describe("Helpers / Range", () => { - it("should return the empty list, given start >= end", () => { + it("should return the empty list, given start > end", () => { expect(range(20, 10)).toEqual([]); - expect(range(10, 10)).toEqual([]); + }); + + it("should return a single element when start equals end", () => { + expect(range(10, 10)).toEqual([10]); }); it("should return every number from start to end, inclusive, given start < end", () => { diff --git a/packages/ui/src/components/Pagination/helpers.ts b/packages/ui/src/components/Pagination/helpers.ts index 54fc9441cb..3840bf5fde 100644 --- a/packages/ui/src/components/Pagination/helpers.ts +++ b/packages/ui/src/components/Pagination/helpers.ts @@ -10,7 +10,7 @@ * ``` */ export function range(start: number, end: number): number[] { - if (start >= end) { + if (start > end) { return []; }