Sitelet https://github.com/angular/components/pull/31269
Skip to content

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

Merged
andrewseguin merged 1 commit into
angular:mainfrom
rslawik:null-undefined
Jul 17, 2025
Merged

andrewseguin merged 1 commit into
angular:mainfrom
rslawik:null-undefined

Conversation

@rslawik

@rslawik rslawik commented May 31, 2025

Copy link
Copy Markdown
Contributor

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

rslawik commented Jul 10, 2025

Copy link
Copy Markdown
Contributor Author

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
@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.
andrewseguin pushed a commit that referenced this pull request Jul 29, 2025
The initial value for `sort` and `paginator` is `undefined` and since #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.
@angular-automatic-lock-bot

Copy link
Copy Markdown

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 Aug 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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