Skip to content

feat(material/table): accept undefined sort and paginator #31269

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

Merged
merged 1 commit into from
Jul 17, 2025

Conversation

rslawik
Copy link
Contributor

@rslawik rslawik commented May 31, 2025

Extend types of the sort and paginator setter to include undefined to avoid ?? null when using singals (e.g. viewChild).

@rslawik rslawik requested a review from a team as a code owner May 31, 2025 16:41
@rslawik rslawik requested review from andrewseguin and ok7sai and removed request for a team May 31, 2025 16:41
@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: material/table labels May 31, 2025
@rslawik
Copy link
Contributor Author

rslawik commented Jul 10, 2025

Based on internal testing: I reduced the scope of this change to only accept undefined in the setter without coercing it to null because the initial values of this._paginator and this._sort are undefined exposed as null. This avoids build and test breakages.

We can accept the casts or consider making a breaking change as a follow up to either:

  1. Initialize this._sort: MatSort | null = null and coerce undefined to null in the setter. There are a handful targets to fix for that.
  2. Expose undefined in get sort(): MatSort | null | undefined and in this._sort. There are a few generic components wrapping the data source to fix.
  3. Replace null with undefined. This should be equivalent to 2 in effort.

Same for the paginator. These are fairly tractable to migrate incrementally, so I can help. But the decision which one should be made by the owner.

Extend types of the sort and paginator setter to include undefined to avoid `?? null` when using
singals (e.g. `viewChild`).
@andrewseguin andrewseguin added the action: merge The PR is ready for merge by the caretaker label Jul 15, 2025
@andrewseguin andrewseguin added the target: minor This PR is targeted for the next minor release label Jul 17, 2025
@andrewseguin andrewseguin merged commit 9627c29 into angular:main Jul 17, 2025
28 checks passed
@rslawik rslawik deleted the null-undefined branch July 24, 2025 08:20
rslawik added a commit to rslawik/angular-components that referenced this pull request Jul 24, 2025
The initial value for `sort` and `paginator` is `undefined` and since angular#31269 the setter accepts
`undefined` too (typically from a signal child query).
This change aligns the getter type with the real type and makes it symmetric with the setter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: merge The PR is ready for merge by the caretaker area: material/table detected: feature PR contains a feature commit target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants