fix(ui): prioritize providedRowCount in useTable hook
Changed the row count calculation in the useTable hook to prioritize the providedRowCount prop over data.length. This ensures accurate row count values in server-side pagination scenarios where the total number of rows differs from the current page's data length. Signed-off-by: Johan Persson <johanopersson@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/ui': patch
|
||||
---
|
||||
|
||||
Fixed `useTable` hook to prioritize `providedRowCount` over data length for accurate row count in server-side pagination scenarios.
|
||||
@@ -50,8 +50,8 @@ export function useTable<T = any>(
|
||||
const isControlled =
|
||||
controlledOffset !== undefined || controlledPageSize !== undefined;
|
||||
|
||||
// Calculate row count from data or use provided value
|
||||
const rowCount = data?.length ?? providedRowCount ?? 0;
|
||||
// Use providedRowCount if passed, otherwise fallback to data length
|
||||
const rowCount = providedRowCount ?? data?.length ?? 0;
|
||||
|
||||
// Internal state for uncontrolled mode
|
||||
const [internalOffset, setInternalOffset] = useState(defaultOffset);
|
||||
|
||||
Reference in New Issue
Block a user