Skip to content

Commit 1a7c19c

Browse files
fix(pagination): allow range function to return single pagefix(pagination): allow range function to return single page (fixes #1048)Update helpers.ts
Changed condition from start >= end to start > end to allow range function to return [start] when start equals end. This fixes the pagination component not showing page 1 when there's only one page. Addresses issue #1048.
1 parent d61afda commit 1a7c19c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/ui/src/components/Pagination/helpers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
* Generates an array of sequential numbers from a start value to an end value (inclusive).
33
* @param start - The starting number of the range
44
* @param end - The ending number of the range
5-
* @returns An array of numbers from start to end. Returns empty array if start is greater than or equal to end.
5+
* @returns An array of numbers from start to end. Returns empty array if start is greater than end.
66
* @example
77
* ```ts
88
* range(1, 5) // returns [1, 2, 3, 4, 5]
99
* range(5, 1) // returns []
10+
* range(1, 1) // returns [1]
1011
* ```
1112
*/
1213
export function range(start: number, end: number): number[] {
13-
if (start >= end) {
14+
if (start > end) {
1415
return [];
1516
}
16-
1717
return [...Array(end - start + 1).keys()].map((key: number): number => key + start);
1818
}

0 commit comments

Comments
 (0)