Skip to content

bug(MatPaginator): pageSizeOptions are required to be mutable Array, ReadonlyArray fails #24050

Closed

Description

@max-vogler

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

MatPaginator requires pageSizeOptions to be a mutable array. Passing in a ReadonlyArray fails.

Reproduction

Steps to reproduce:

@Component({
  selector: 'example-component',
  template: '<mat-paginator [pageSizeOptions]="pageSizeOptions"></mat-paginator>',
})
export class ExampleComponent {
 pageSizeOptions: ReadonlyArray<number> = [10, 20];
}

https://stackblitz.com/edit/components-issue-rvmtli?file=src/app/example-component.ts

Expected Behavior

I am unaware that MatPaginator would mutate the passed in Array. Passing in a ReadonlyArray should work.

Actual Behavior

Throws

The type 'readonly number[]' is 'readonly' and cannot be assigned to the mutable type 'number[]'.

Environment

  • Angular: ^12.2.9
  • CDK/Material: ^12.2.9
  • TypeScript: ^3.7.5
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS

Activity

  1. added
    needs triage
    on Dec 3, 2021
  2. added a commit that references this issue on Dec 3, 2021
    9e0a2ad
  3. added
    P4
    and removed
    needs triage
    on Dec 6, 2021
  4. added a commit that references this issue on Jan 15, 2022
    d1a2769
  5. added 2 commits that reference this issue on Jan 18, 2022
    a4f6558
    772176a
  6. angular-automatic-lock-bot commented on Feb 18, 2022

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  7. locked and limited conversation to collaborators on Feb 18, 2022
  8. added a commit that references this issue on Apr 3, 2022
    7debdfe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4area: material/paginator

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions