[ix-pagination] Add option to decide on number of items#2364
[ix-pagination] Add option to decide on number of items#2364varun-srinivasa wants to merge 8 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 09e8ddf The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Summary of ChangesHello @varun-srinivasa, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a valuable feature allowing developers to customize the item count options in the pagination component. The implementation is solid, including the addition of the itemCountOptions property, validation logic, and corresponding tests. I've identified a couple of areas for improvement concerning code duplication and a minor bug in the fallback logic, along with a suggestion to enhance rendering performance. Overall, the changes are well-implemented and tested.
| @Watch('itemCountOptions') | ||
| onItemCountOptionsChange() { | ||
| if (this.advanced && !this.hideItemCount) { | ||
| this.verifiedItemCountOptions = this.getValidItemCountOptions(); | ||
| this.verifyEmptyItemCountOptions(); | ||
| this.verifyAllInvalidItemCountOptions(); | ||
| this.verifyItemCountMismatch(); | ||
| } | ||
| } | ||
|
|
||
| componentWillLoad() { | ||
| if (!this.advanced || this.hideItemCount) { | ||
| return; | ||
| } | ||
|
|
||
| this.verifiedItemCountOptions = this.getValidItemCountOptions(); | ||
| this.verifyEmptyItemCountOptions(); | ||
| this.verifyAllInvalidItemCountOptions(); | ||
| this.verifyItemCountMismatch(); | ||
| } |
There was a problem hiding this comment.
The logic within onItemCountOptionsChange and componentWillLoad is duplicated. To improve maintainability and prevent potential inconsistencies, this logic should be extracted into a single private method.
private _verifyItemCountOptions() {
if (!this.advanced || this.hideItemCount) {
return;
}
this.verifiedItemCountOptions = this.getValidItemCountOptions();
this.verifyEmptyItemCountOptions();
this.verifyAllInvalidItemCountOptions();
this.verifyItemCountMismatch();
}
@Watch('itemCountOptions')
onItemCountOptionsChange() {
this._verifyItemCountOptions();
}
componentWillLoad() {
this._verifyItemCountOptions();
}
| <ix-select-item label="40" value="40"></ix-select-item> | ||
| <ix-select-item label="100" value="100"></ix-select-item> | ||
| {( | ||
| this.verifiedItemCountOptions || this.getValidItemCountOptions() |
There was a problem hiding this comment.
Calling getValidItemCountOptions() within the render function can lead to performance degradation, as it will be executed on every render cycle. The verifiedItemCountOptions property is initialized in componentWillLoad and updated by a watcher, ensuring it holds the correct value when the dropdown is rendered. You can safely rely on verifiedItemCountOptions directly.
this.verifiedItemCountOptions
|
|
||
| private readonly maxCountPages = 7; | ||
| private readonly defaultItemCountOptions = [10, 15, 20, 40, 100]; | ||
| private readonly itemCountOptionsPropName = 'itemCountOptions'; |
There was a problem hiding this comment.
This can be hard coded in the console.warnings
|
|
||
| private readonly maxCountPages = 7; | ||
| private readonly defaultItemCountOptions = [10, 15, 20, 40, 100]; | ||
| private readonly itemCountOptionsPropName = 'itemCountOptions'; |
There was a problem hiding this comment.
This can be hard coded in the console.warnings
|



💡 What is the current behavior?
GitHub Issue Number: #2103
🆕 What is the new behavior?
Added a new property where developers can put in any number for the item select
🏁 Checklist
A pull request can only be merged if all of these conditions are met (where applicable):
pnpm test)pnpm lint)pnpm build, changes pushed)👨💻 Help & support