-
Notifications
You must be signed in to change notification settings - Fork 78
feat(FR-1678): Add automatic page adjustment to BAITable #4636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has required the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Coverage report for
|
St.❔ |
Category | Percentage | Covered / Total |
|---|---|---|---|
| 🔴 | Statements | 49.62% | 132/266 |
| 🔴 | Branches | 29.96% | 80/267 |
| 🔴 | Functions | 33.33% | 20/60 |
| 🔴 | Lines | 51.95% | 120/231 |
Test suite run success
55 tests passing in 3 suites.
Report generated by 🧪jest coverage report action from 6733508
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds automatic page adjustment functionality to BAITable to prevent users from being stuck on invalid pages when data changes reduce the total number of items. The feature defaults to enabled but can be disabled via configuration.
Key changes:
- Added
autoAdjustCurrentPageoption to pagination config (defaults to true) - Implemented automatic page correction when current page exceeds maximum available page
- Used
useEffectEventhook to handle adjustment logic
| interface BAITablePaginationConfig | ||
| extends Omit<TablePaginationConfig, 'position'> { | ||
| /** Additional content to display in the pagination area */ | ||
| extraContent?: ReactNode; |
Copilot
AI
Nov 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new autoAdjustCurrentPage property is missing JSDoc documentation. Please add a comment describing what this option does, its default value, and when it should be disabled.
Suggested documentation:
/** Whether to automatically adjust the current page when it exceeds the maximum available page (defaults to true) */
autoAdjustCurrentPage?: boolean;| extraContent?: ReactNode; | |
| extraContent?: ReactNode; | |
| /** | |
| * Whether to automatically adjust the current page when it exceeds the maximum available page (defaults to true) | |
| */ |
| }, [ | ||
| tableProps.dataSource, | ||
| tableProps.pagination, | ||
| autoAdjustCurrentPage, | ||
| currentPage, | ||
| currentPageSize, | ||
| ]); |
Copilot
AI
Nov 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The useEffect dependency array includes adjustCurrentPage, but since adjustCurrentPage is created by useEffectEvent (which should have stable identity), it shouldn't be included in the dependency array. However, since useEffectEvent is not a real React API (see other comment), this needs to be fixed.
When you switch to useEventNotStable (as recommended), remove adjustCurrentPage from the dependency array since that hook returns a stable function reference:
useEffect(() => {
if (tableProps.pagination && autoAdjustCurrentPage) {
adjustCurrentPage();
}
}, [
tableProps.dataSource,
tableProps.pagination,
autoAdjustCurrentPage,
currentPage,
currentPageSize,
// adjustCurrentPage should be removed as useEventNotStable returns a stable reference
]);
resolves #4634 (FR-1678)
This PR adds an auto-adjustment feature to the BAITable pagination that automatically corrects the current page when it exceeds the maximum available page after data changes. This prevents users from being stuck on an invalid page when filtering or data updates reduce the total number of items.
Key changes:
autoAdjustCurrentPageoption to pagination config (defaults to true)useEffectEventto handle the adjustment logic properlyChecklist: (if applicable)