Skip to content

bug(stepper): access to undefined #30864

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

Closed
1 task
it11ah1 opened this issue Apr 14, 2025 · 0 comments · Fixed by #30944
Closed
1 task

bug(stepper): access to undefined #30864

it11ah1 opened this issue Apr 14, 2025 · 0 comments · Fixed by #30944
Assignees
Labels
area: cdk/stepper P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@it11ah1
Copy link

it11ah1 commented Apr 14, 2025

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

In steppers _updateSelectedItemIndex() this._keyManager is used without checking for undefined.
A problem occurs when calling reset(); after getting the stepper element from viewChild("stepper");

Reproduction

You can see the problem in the sources. No StackBlitz needed.

Expected Behavior

Calling reset() without TypeError

Actual Behavior

TypeError: Cannot read properties of undefined (reading 'updateActiveItem')

Environment

  • Angular: 19.2.2
  • CDK/Material: 19.2.3
@it11ah1 it11ah1 added the needs triage This issue needs to be triaged by the team label Apr 14, 2025
@crisbeto crisbeto self-assigned this Apr 24, 2025
@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent area: cdk/stepper and removed needs triage This issue needs to be triaged by the team labels Apr 24, 2025
crisbeto added a commit to crisbeto/material2 that referenced this issue Apr 24, 2025
The stepper initializes its key manager in `ngAfterViewInit`, but uses it in methods that can technically be called before it is available. These changes add some null checks and update the type to avoid throwing errors.

Fixes angular#30864.
crisbeto added a commit that referenced this issue Apr 24, 2025
The stepper initializes its key manager in `ngAfterViewInit`, but uses it in methods that can technically be called before it is available. These changes add some null checks and update the type to avoid throwing errors.

Fixes #30864.
crisbeto added a commit that referenced this issue Apr 24, 2025
The stepper initializes its key manager in `ngAfterViewInit`, but uses it in methods that can technically be called before it is available. These changes add some null checks and update the type to avoid throwing errors.

Fixes #30864.

(cherry picked from commit 6bdea0b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: cdk/stepper P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants