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

fix(a11y): inconsistent runtime value for ListKeyManager.activeItem #14154

Merged

Conversation

crisbeto
Copy link
Member

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.

@crisbeto crisbeto added the target: patch This PR is targeted for the next patch release label Nov 15, 2018
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 15, 2018

this._activeItemIndex = index;
this._activeItem = itemArray[index];
this._activeItem = typeof activeItem === 'undefined' ? null : activeItem;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this._activeItem = activeItem == null ? null : activeItem; is shorter no ?

@crisbeto crisbeto force-pushed the 14152/list-key-manager-active-item branch from 3410334 to 4c7409d Compare November 15, 2018 13:25
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


this._activeItemIndex = index;
this._activeItem = itemArray[index];
this._activeItem = activeItem == null ? null : activeItem;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment like

// Explicitly check for `null` and `undefined` because other falsy values are valid.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
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 added the action: merge The PR is ready for merge by the caretaker label Nov 15, 2018
@crisbeto crisbeto force-pushed the 14152/list-key-manager-active-item branch from 4c7409d to 119005e Compare November 15, 2018 21:23
@mmalerba mmalerba merged commit c4b3484 into angular:master Dec 4, 2018
mmalerba pushed a commit that referenced this pull request 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 pull request 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
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ListKeyManager activeItem property has wrong type
5 participants