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

ListKeyManager activeItem property has wrong type #14152

Closed
szymonbultrowicz opened this issue Nov 15, 2018 · 1 comment · Fixed by #14154
Closed

ListKeyManager activeItem property has wrong type #14152

szymonbultrowicz opened this issue Nov 15, 2018 · 1 comment · Fixed by #14154
Assignees
Labels
P4 A relatively minor issue that is not relevant to core functions

Comments

@szymonbultrowicz
Copy link

Bug, feature request, or proposal:

ListKeyManager activeItem property has a wrong type

What is the expected behavior?

The activeItem property can be undefined in some cases, so the typing should be aware of the undefined as well. Another way would be to handle undefined value and return null then.

What is the current behavior?

The activeItem type is set to T | null, but happens to return undefined.

What are the steps to reproduce?

https://stackblitz.com/edit/angular-material-ticket-active-item-type

What is the use-case or motivation for changing an existing behavior?

In some cases (no value selected, non-existing value selected) the property can be also undefined which is not suggested by typing. Due to that fact, we recently faced a null pointer exception, because we only handled null value.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

It affects @angular/cdk in version 6.3.0+ for sure, although it looks like the code is quite old, so previous version are probably affected as well.

crisbeto added a commit to crisbeto/material2 that referenced this issue Nov 15, 2018
The `activeItem` is currently typed to `T | null`, however on init and when assigning incorrect values, the `activeItem` will actually be `undefined` at runtime. These changes add some logic to make sure that the value is consistent with its type.

Fixes angular#14152.
@crisbeto crisbeto self-assigned this Nov 15, 2018
@crisbeto crisbeto added has pr P4 A relatively minor issue that is not relevant to core functions labels Nov 15, 2018
crisbeto added a commit to crisbeto/material2 that referenced this issue Nov 15, 2018
The `activeItem` is currently typed to `T | null`, however on init and when assigning incorrect values, the `activeItem` will actually be `undefined` at runtime. These changes add some logic to make sure that the value is consistent with its type.

Fixes angular#14152.
crisbeto added a commit to crisbeto/material2 that referenced this issue Nov 15, 2018
The `activeItem` is currently typed to `T | null`, however on init and when assigning incorrect values, the `activeItem` will actually be `undefined` at runtime. These changes add some logic to make sure that the value is consistent with its type.

Fixes angular#14152.
mmalerba pushed a commit that referenced this issue Dec 4, 2018
…14154)

The `activeItem` is currently typed to `T | null`, however on init and when assigning incorrect values, the `activeItem` will actually be `undefined` at runtime. These changes add some logic to make sure that the value is consistent with its type.

Fixes #14152.
mmalerba pushed a commit that referenced this issue Dec 10, 2018
…14154)

The `activeItem` is currently typed to `T | null`, however on init and when assigning incorrect values, the `activeItem` will actually be `undefined` at runtime. These changes add some logic to make sure that the value is consistent with its type.

Fixes #14152.
josephperrott pushed a commit to josephperrott/components that referenced this issue Jan 14, 2019
…ngular#14154)

The `activeItem` is currently typed to `T | null`, however on init and when assigning incorrect values, the `activeItem` will actually be `undefined` at runtime. These changes add some logic to make sure that the value is consistent with its type.

Fixes angular#14152.
@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 Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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