Repository navigation
fix(aria/accordion): avoid errors when destroyed before initialization - #34061
Open
nagahara-naoki wants to merge 2 commits into
Open
nagahara-naoki wants to merge 2 commits into
nagahara-naoki wants to merge 2 commits into
Conversation
Retain the panel associated during initialization so destruction does not read an unset required input. Cover early destruction and verify that initialized triggers still clear their panel association. Fixes angular#34060
Open
1 task
Member
|
See the comment #34059 (comment) |
Contributor
Author
|
Thanks! I’ll apply the same approach here and verify it with tests. |
Keep panel registration and cleanup together using an effect instead of a retained reference. Cover panel input changes and update the API golden for removed lifecycle hooks.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #34060.
AccordionTrigger.ngOnDestroy()reads the requiredpanel()input even if the trigger is destroyed before the first change detection andngOnInithas not run. Destroying a newly created TestBed fixture therefore throws NG0950, despite the template binding[panel]correctly.Retain the panel associated during
ngOnInitand only clear that association during destruction if initialization established it. Unregistering from the group remains safe for an unregistered trigger. This follows the registration/cleanup approach in #33974 (combobox).Adds an early-destruction regression test and an initialized control that verifies the panel association exists before destruction and is cleared afterward. The changes are based on main after #34053.
Related Tree PR: #34059. This PR is independent and contains only accordion changes.
Validation
NG0950: Input "panel" is required but no value is available yet.The initialized control passes.pnpm test src/aria/accordion --no-watchpasses: 45 specs, 0 failures, including the strengthened initialized cleanup assertion.pnpm bazelisk test //goldens:aria_apipasses.pnpm ng-dev format changed --checkpasses.git diff --checkand commit-message validation pass.Tested with Node.js 22.23.4 and pnpm 12.16.1 on macOS arm64. The full Material/CDK/Aria test suites and Firefox were not run locally. Complete reproduction code, steps, environment, and actual error are in #34060.