Skip to content
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

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

Closed
1 task
max-vogler opened this issue Dec 3, 2021 · 1 comment · Fixed by #24054
Closed
1 task
Labels
area: material/paginator P4 A relatively minor issue that is not relevant to core functions

Comments

@max-vogler
Copy link

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
@max-vogler max-vogler added the needs triage This issue needs to be triaged by the team label Dec 3, 2021
lekhmanrus added a commit to lekhmanrus/components that referenced this issue Dec 3, 2021
@crisbeto crisbeto added area: material/paginator has pr P4 A relatively minor issue that is not relevant to core functions and removed needs triage This issue needs to be triaged by the team labels Dec 6, 2021
lekhmanrus added a commit to lekhmanrus/components that referenced this issue Jan 15, 2022
andrewseguin pushed a commit that referenced this issue Jan 18, 2022
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 18, 2022
forsti0506 pushed a commit to forsti0506/components that referenced this issue Apr 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/paginator P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants