bug(aria/combobox): ComboboxPopup throws NG0950 when destroyed before its first change detection
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 78/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- angular, typescript
- Domaine
- accessibility, frontend
Piste de recherche
Commencez dans src/aria/combobox/combobox-popup.ts, en particulier dans ngOnDestroy, et vérifiez l’enregistrement du cycle de vie du composant ainsi que son comportement de teardown. Reproduisez le problème avec le test fourni, qui crée une fixture et la détruit sans exécuter la détection des changements. Le résultat attendu est que le teardown ne lise plus un input requis non défini et que le test passe.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
ComboboxPopup.ngOnDestroy calls this.combobox()._unregisterPopup(). The combobox input is input.required(). If the view that holds the popup is destroyed before its first update pass, the input was never set, and reading it throws NG0950: Input "combobox" is required but no value is available yet. Angular reports this as "Error during cleanup of component", and in tests it fails the test ("1 fixture threw errors during cleanup").
This happens in any unit test that creates a component containing a combobox and does not run change detection before teardown, for example a plain "should create" test, or a test that only checks providers.
Reproduction
import { Component } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { Combobox, ComboboxPopup, ComboboxWidget } from '@angular/aria/combobox';
import { Listbox, Option } from '@angular/aria/listbox';
@Component({
imports: [Combobox, ComboboxPopup, ComboboxWidget, Listbox, Option],
template: `
<div ngCombobox #combobox="ngCombobox" tabindex="0">Pick one</div>
<ng-template ngComboboxPopup [combobox]="combobox">
<div ngListbox ngComboboxWidget #listbox="ngListbox" focusMode="activedescendant"
[activeDescendant]="listbox.activeDescendant()">
<div ngOption value="alpha" label="alpha">alpha</div>
</div>
</ng-template>
`,
})
class Repro {}
it('destroys cleanly before the first change detection', () => {
const fixture = TestBed.createComponent(Repro);
expect(() => fixture.destroy()).not.toThrow(); // throws NG0950
});
Expected Behavior
Destroying the popup without a first change detection does nothing (there is nothing to unregister).
Actual Behavior
NG0950: Input "combobox" is required but no value is available yet, from ComboboxPopup.ngOnDestroy (src/aria/combobox/combobox-popup.ts, line 67 on main).
A possible fix: register in ngOnInit and keep the registered combobox in a field, then unregister that field (if set) in ngOnDestroy, instead of reading the input again.
Workaround: wrap the ng-template ngComboboxPopup in @if (combobox) { … }, so the popup is only created in an update pass.
Environment
- Angular: 22.2.1
- CDK/Material: @angular/cdk 22.2.3, @angular/aria 22.2.3 (also in 22.3.0-next.2 and
main) - Browser(s): any (seen in Vitest with happy-dom)
- Operating System (e.g. Windows, macOS, Ubuntu): macOS
- Langage dominant
- TypeScript
- Étoiles
- 25k
- Forks
- 6.8k
- Merge moyen
- 2 j 19 h
- PR mergées (30 j)
- 82
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de angular/components
-
bug(aria/combobox): keys pressed back to back are lost; only the last one reaches the popupPeut-être pris @drakeo338 l’a pris il y a 2 jours. Ouvertearea: aria/combobox gemini-triaged
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
angular/components#33973 ·
Les mainteneurs répondent en général sous 1 jour
-
bug(material/sort): hover hint arrow on an unsorted header shows the active sort direction, not the resulting direction after click.Peut-être pris @lekhmanrus l’a pris il y a 14 jours. Ouvertearea: material/sort P3
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
angular/components#33933 ·
Les mainteneurs répondent en général sous 1 jour
-
bug(mat-date-picker): month shown twice in date pickerPeut-être pris @PreethiPantangi l’a pris il y a 31 jours. Ouvertearea: material/datepicker P4
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
angular/components#33763 · 2 commentaires · 3 réactions ·
Les mainteneurs répondent en général sous 1 jour
-
Bug in table.scss footer cell height: unset instead of footer row height unsetPeut-être pris @minwookshin l’a pris il y a 18 jours. Ouvertearea: material/table P4
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
angular/components#33709 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
docs-bug(Table): Add example with `rowspan`Peut-être pris @BHUVANSH855 l’a pris il y a 99 jours. Ouvertearea: material/table docs P4
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
angular/components#33455 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de angular/components
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
kunchenguid/gh-axi#220 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 79/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour
-
prerender: wait for env-runner worker readiness before crawlingPeut-être pris @sarankumar1325 l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour