-
Notifications
You must be signed in to change notification settings - Fork 36
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
2525 Allow IcPaginationBar items per page to be set programmatically #2999
2525 Allow IcPaginationBar items per page to be set programmatically #2999
Conversation
d28efd8
to
9b607d5
Compare
9b607d5
to
d0128b9
Compare
packages/canary-react/src/stories/ic-pagination-bar.stories.mdx
Outdated
Show resolved
Hide resolved
e3ac8c3
to
3a6ea44
Compare
we seem to be seeing the same issue here with generated images. if you want to add a .skip for these 2 & we will get them added back in after this is merged, please feel free |
461f7f3
to
0a22433
Compare
0a22433
to
bbfcfe5
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.
Just spotted a couple of things
Hopefully a rebase should fix the audit issue as well :)
@@ -85,7 +85,40 @@ export class PaginationBar { | |||
|
|||
@Watch("currentPage") | |||
watchPageNumberHandler(): void { | |||
this.activePage = this.currentPage; | |||
if (typeof this.currentPage === "number" && this.currentPage) { | |||
if (this.totalPages && this.currentPage > this.totalPages) { |
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.
Should this if statement also check that currentPage is greater than zero?
if (this.totalPages && this.currentPage > this.totalPages) { | |
if (this.totalPages && this.currentPage > this.totalPages || this.currentPage < 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.
Agreed - I have added this check and also added a new story to ic-pagination-bar that demonstrates the validation in action.
I have also added a new story to ic-pagination-bar to show the selectedItemsPerPage prop when this is set to an invalid value.
(option) => option.value === `${this.selectedItemsPerPage}` | ||
).length | ||
) { | ||
this.itemsPerPageString = `${this.selectedItemsPerPage}`; |
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.
Is this line needed? this.itemsPerPageString
gets updated within the setItemsPerPage
function which is being called below
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.
Yes well spotted - I have removed this.
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.
See comments above
435640a
to
dbc5977
Compare
dbc5977
to
90b0b7f
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.
Building locally (npm build:all
) is showing some changes to the docs & date-input readme. Would you mind just checking if it's showing any uncommitted changes for you?
(this.totalPages && this.currentPage > this.totalPages) | ||
) { | ||
console.error( | ||
"Current page must be a number greater than zero but less than or equal to the total number of pages" |
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.
might be nice to show the value it's been given, like you have for the selectedItemsPerPage
console error?
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.
Agreed - I have updated this so it now includes the current page and the total number of pages in the console error message. At the same time I also fixed a bug in the validation of current page > total pages.
90b0b7f
to
9e7105e
Compare
An extension to this could be the ability to set the selected option to "All", but happy for this to be a separate ticket |
The selected items per page option is passed in using its numerical value. So it the available dropdown options are: [10, 25, All] and there are, say, 120 items, if you pass in 120 then the All option will become selected. Perhaps there is a clearer way of doing this, if so then yes it would be better in a separate ticket. |
9e7105e
to
13e94bf
Compare
There were 3 files with some minor content changes, I have added these to the PR |
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.
Please can you remove the docs scope commit? It shouldn't be introduced by your changes, so we will fix separately rather than make it part of this work
13e94bf
to
31c1ab7
Compare
31c1ab7
to
1bc01f8
Compare
Summary of the changes
A new selectedItemsPerPage prop has been added to the IcPaginationBar that allows the selected items per page dropdown option to be set programmatically.
Error handling has been included such that if the selectedItemsPerPage prop is set to a value that does not correspond to one of the available items per page dropdown options, an error will appear in the console.
Also, some error handling has been added to the IcPaginationBar currentPage prop, because it was possible to set the current page to a number that was larger than the total number of pages. Now, if this is attempted the modification of the current page is prevented and an error appears in the console.
Also, a very minor code tidy-up has been performed in the IcDataTable.
Related issue
#2525
Checklist
General
Testing
Accessibility
Resize/zoom behaviour
System modes
Testing content extremes