fix(Table): sanitize paginateData page index fixes #3593
Summary
- Clamp pagination
pageinpaginateDataso invalid values are normalized to page1. - Preserve existing
pageSizebehavior (Math.max(1, Math.floor(pageSize))). - Added regression tests for negative, fractional, and non-finite page values.
Why
Array.slicetreats negative/invalid offsets in ways that can silently return wrong rows (end-of-array slices and overlapping ranges).- Query params and shared client state can produce
-1,1.5, etc., so this avoids wrong rows shown under valid-looking pagination UI.
Closes #3593
@ahfoysal is attempting to deploy a commit to the Meta Open Source Team on Vercel.
A member of the Team first needs to authorize it.
Thank you so much for this, @ahfoysal — and for the care in the writeup (the "negative page index slices from the end of the array" explanation is exactly the right diagnosis). 🙏
Closing this one only because both fixes have since landed on main independently:
paginateDatapage clamp (#3593) → fixed in #3594 —mainnow coercespagewithMath.max(1, Math.floor(page)), the same approach you took here.Textsizeoverride (#3615) → fixed in #3648 —Textnow appliessizeviasizeStyles[size]and threads it throughthemeProps, matching what you had.
Both issues (#3593, #3615) are closed as a result. The merge conflict here is really just the two sides having implemented the same fixes — so there's nothing left to rebase in, unfortunately, which is the one downside of the timing.
None of that diminishes the contribution — you correctly identified and fixed two real bugs; they just got resolved in parallel while this sat in the queue. Really appreciate you digging in, and we'd love to have more from you. If you're up for another, the good first issues are a good place to find something that's still open. Thanks again! 🎉