From 1a7c19c39521d5ebe859db8a459cd7161b34590d Mon Sep 17 00:00:00 2001 From: DHANUSH RAJA <155062318+DHANUSHRAJA22@users.noreply.github.com> Date: Wed, 27 Aug 2025 16:24:07 +0530 Subject: [PATCH] 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. --- packages/ui/src/components/Pagination/helpers.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/components/Pagination/helpers.ts b/packages/ui/src/components/Pagination/helpers.ts index 54fc9441cb..b8d2f00bed 100644 --- a/packages/ui/src/components/Pagination/helpers.ts +++ b/packages/ui/src/components/Pagination/helpers.ts @@ -2,17 +2,17 @@ * Generates an array of sequential numbers from a start value to an end value (inclusive). * @param start - The starting number of the range * @param end - The ending number of the range - * @returns An array of numbers from start to end. Returns empty array if start is greater than or equal to end. + * @returns An array of numbers from start to end. Returns empty array if start is greater than end. * @example * ```ts * range(1, 5) // returns [1, 2, 3, 4, 5] * range(5, 1) // returns [] + * range(1, 1) // returns [1] * ``` */ export function range(start: number, end: number): number[] { - if (start >= end) { + if (start > end) { return []; } - return [...Array(end - start + 1).keys()].map((key: number): number => key + start); }