Repository navigation
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
Closed
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.
crisbeto
approved these changes
Nov 11, 2026
Member
crisbeto
pushed a commit
that referenced
this pull request
Nov 11, 2026
#34061) * fix(aria/accordion): avoid errors when destroyed before initialization 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 #34060 * fix(aria/accordion): manage registration with effects 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. (cherry picked from commit 17b4f1f)
DuncanFaulkner
added a commit
to DuncanFaulkner/components
that referenced
this pull request
Nov 30, 2026
…fter first render Since angular#34061, `AccordionTrigger` links itself to its panel inside an effect, which can run after the panel's first render. `AccordionPanel.visible` is a computed over `_pattern`, which was a plain field. If anything reads `visible()` before the trigger links (for example a template binding such as `[class.hidden]="!panel.visible()"`), the computed caches `false` with no reactive dependencies and never re-evaluates. The panel's own `[attr.inert]` host binding reads the same computed, so the panel stays hidden and inert even though the trigger reports `aria-expanded="true"`. The panel's `_pattern` field is replaced by a `_triggerPattern` signal that the trigger sets, so `visible()` updates when the trigger links or unlinks the panel.
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.