Skip to content

fix(aria/accordion): avoid errors when destroyed before initialization - #34061

Open
nagahara-naoki wants to merge 2 commits into
angular:mainfrom
nagahara-naoki:fix-aria-accordion-destroy-before-init
Open

nagahara-naoki wants to merge 2 commits into
angular:mainfrom
nagahara-naoki:fix-aria-accordion-destroy-before-init

Conversation

@nagahara-naoki

@nagahara-naoki nagahara-naoki commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #34060.

AccordionTrigger.ngOnDestroy() reads the required panel() input even if the trigger is destroyed before the first change detection and ngOnInit has not run. Destroying a newly created TestBed fixture therefore throws NG0950, despite the template binding [panel] correctly.

Retain the panel associated during ngOnInit and 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

  • Before the fix, the Chromium accordion suite reports 44 passed, 1 failed; the new early-destruction test throws NG0950: Input "panel" is required but no value is available yet. The initialized control passes.
  • After the fix, pnpm test src/aria/accordion --no-watch passes: 45 specs, 0 failures, including the strengthened initialized cleanup assertion.
  • pnpm bazelisk test //goldens:aria_api passes.
  • pnpm ng-dev format changed --check passes.
  • TSLint passes for both changed TypeScript files.
  • git diff --check and 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.

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
@ok7sai

ok7sai commented Nov 5, 2026

Copy link
Copy Markdown
Member

See the comment #34059 (comment)

@nagahara-naoki

Copy link
Copy Markdown
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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(aria/accordion): NG0950 when a trigger is destroyed before its first change detection

2 participants