-
Notifications
You must be signed in to change notification settings - Fork 207
feat: implement jump to page #4113
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
4a1ead1 to
ab579b4
Compare
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.
To update snapshots: npm run build && npx jest -c jest.unit.config.js -u documenter test-util
| }, | ||
| }; | ||
|
|
||
| const renderMainInput = () => ( |
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.
const renderMainInput = <WithNativeAttributes....
| margin-block-start: calc(awsui.$space-scaled-xs * -1); | ||
| } | ||
|
|
||
| .inline-label { |
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.
move this to mixin so it can be reused between select and input, probably move to https://github.com/cloudscape-design/components/blob/main/src/internal/styles/forms/mixins.scss
| }; | ||
|
|
||
| const defaultI18nStrings: Required<PaginationProps.I18nStrings> = { | ||
| jumpToPageLabel: 'Page', |
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.
remove hardcoded strings
| loading?: boolean; | ||
| } | ||
|
|
||
| export interface JumpToPageRef { |
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.
name Ref
| type InternalPaginationProps = PaginationProps & InternalBaseComponentProps; | ||
| type InternalPaginationProps = PaginationProps & | ||
| InternalBaseComponentProps & { | ||
| jumpToPageRef?: React.Ref<PaginationProps.JumpToPageRef>; |
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.
use forwardRef on the internal component as well, rather than manually adding it to the props
| function handleJumpToPageClick(requestedPageIndex: number) { | ||
| if (requestedPageIndex < 1) { | ||
| // Out of range lower bound - navigate to first page | ||
| setJumpToPageValue('1'); |
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.
replace these 3 lines with handlePageClick(1)
| handlePageClick(requestedPageIndex); | ||
| } else { | ||
| // Out of range - set error and navigate to last page | ||
| setHasError(true); |
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.
use handlePageClick here (with additional param for error state)
| tableComponentContext.paginationRef.current.openEnd = openEnd; | ||
| } | ||
|
|
||
| const renderJumpToPageButton = () => { |
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.
plain value rather than function
| /** | ||
| * Returns the error popover for jump to page. | ||
| */ | ||
| findPopover(): PopoverWrapper | null { |
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.
findJumpToPagePopover
Description
The current pagination component forces users to navigate sequentially through pages, creating poor user experience for large datasets. Users frequently need to access specific pages (e.g., jumping from page 1 to page 50) but must click through each intermediate page, leading to time-consuming navigation for large datasets. This change proposes additional options for user to navigate to a specific page.
How has this been tested?
Added examples of open-ended and closed-ended scenarios under tables pages
Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md.CONTRIBUTING.md.Security
checkSafeUrlfunction.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.