astryx icon indicating copy to clipboard operation
astryx copied to clipboard

fix(Table): sanitize paginateData page index fixes #3593

Open ahfoysal opened this issue 4 months ago • 1 comments

Summary

  • Clamp pagination page in paginateData so invalid values are normalized to page 1.
  • Preserve existing pageSize behavior (Math.max(1, Math.floor(pageSize))).
  • Added regression tests for negative, fractional, and non-finite page values.

Why

  • Array.slice treats 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 avatar Jul 07 '26 07:07 ahfoysal

@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.

vercel[bot] avatar Jul 07 '26 07:07 vercel[bot]

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:

  • paginateData page clamp (#3593) → fixed in #3594 — main now coerces page with Math.max(1, Math.floor(page)), the same approach you took here.
  • Text size override (#3615) → fixed in #3648 — Text now applies size via sizeStyles[size] and threads it through themeProps, 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! 🎉

cixzhang avatar Jul 19 '26 19:07 cixzhang