Skip to content

[ix-pagination] Add option to decide on number of items#2364

Open
varun-srinivasa wants to merge 8 commits intomainfrom
pagination
Open

[ix-pagination] Add option to decide on number of items#2364
varun-srinivasa wants to merge 8 commits intomainfrom
pagination

Conversation

@varun-srinivasa
Copy link
Collaborator

💡 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):

  • 🦮 Accessibility (a11y) features were implemented
  • 🗺️ Internationalization (i18n) - no hard coded strings
  • 📲 Responsiveness - components handle viewport changes and content overflow gracefully
  • 📕 Add or update a Storybook story
  • 📄 Documentation was reviewed/updated siemens/ix-docs
  • 🧪 Unit tests were added/updated and pass (pnpm test)
  • 📸 Visual regression tests were added/updated and pass (Guide)
  • 🧐 Static code analysis passes (pnpm lint)
  • 🏗️ Successful compilation (pnpm build, changes pushed)

👨‍💻 Help & support

@changeset-bot
Copy link

changeset-bot bot commented Jan 28, 2026

🦋 Changeset detected

Latest commit: 09e8ddf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@siemens/ix-angular Minor
@siemens/ix Minor
@siemens/ix-react Minor
@siemens/ix-vue Minor
@siemens/ix-docs Minor

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

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 ix-pagination component by introducing the itemCountOptions property. This new feature empowers developers to fully customize the available choices for "items per page" in the pagination control, moving beyond a fixed set of options. The implementation includes robust validation, automatic sorting, and intelligent fallback mechanisms to ensure data integrity and a smooth user experience, while also providing helpful warnings for potential configuration issues.

Highlights

  • Customizable Item Count Options: Introduced a new itemCountOptions property for the ix-pagination component, allowing developers to specify a custom array of numbers for the "items per page" dropdown.
  • Robust Input Validation: Implemented comprehensive validation for itemCountOptions, which automatically filters out non-positive integers and duplicate values, ensuring only valid, sorted options are used.
  • Intelligent Fallback Mechanisms: The component now gracefully handles scenarios where itemCountOptions is empty or contains only invalid values, falling back to a predefined set of default options.
  • Configuration Mismatch Warnings: Added console warnings to alert developers if the itemCount property's value is not present within the provided itemCountOptions, helping prevent invalid dropdown states.
  • Framework Integration & Testing: The new itemCountOptions property has been integrated across Angular, React, and Vue wrappers, and new regression tests ensure its correct behavior and validation logic.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +135 to +154
@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();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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

@varun-srinivasa varun-srinivasa marked this pull request as ready for review January 30, 2026 05:04

private readonly maxCountPages = 7;
private readonly defaultItemCountOptions = [10, 15, 20, 40, 100];
private readonly itemCountOptionsPropName = 'itemCountOptions';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be hard coded in the console.warnings

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 4, 2026

@nuke-ellington nuke-ellington added this to the 4.4.0 milestone Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants