bug(aria/combobox): ComboboxPopup throws NG0950 when destroyed before its first change detection
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 78/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- angular, typescript
- Domínio
- accessibility, frontend
Direção de pesquisa
Comece em src/aria/combobox/combobox-popup.ts, especialmente em ngOnDestroy, e verifique o registro do ciclo de vida e o comportamento de teardown do componente. Reproduza o problema com o teste fornecido, que cria um fixture e o destrói sem executar a detecção de alterações. O objetivo é alcançado quando o teardown deixa de ler um input obrigatório não definido e o teste passa.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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
- Linguagem predominante
- TypeScript
- Estrelas
- 25k
- Forks
- 6.8k
- Merge médio
- 1d 5h
- PRs com merge (30d)
- 67
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de angular/components
-
area: aria/combobox gemini-triaged
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
angular/components#33973 ·
Mantenedores costumam responder em até 1 dia
-
bug(material/sort): hover hint arrow on an unsorted header shows the active sort direction, not the resulting direction after click.Talvez já em andamento @lekhmanrus assumiu há 11 dias. Abertaarea: material/sort P3
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
angular/components#33933 ·
Mantenedores costumam responder em até 1 dia
-
bug(mat-date-picker): month shown twice in date pickerTalvez já em andamento @PreethiPantangi assumiu há 29 dias. Abertaarea: material/datepicker P4
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
angular/components#33763 · 2 comentários · 3 reações ·
Mantenedores costumam responder em até 1 dia
-
Bug in table.scss footer cell height: unset instead of footer row height unsetTalvez já em andamento @minwookshin assumiu há 15 dias. Abertaarea: material/table P4
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
angular/components#33709 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
docs-bug(Table): Add example with `rowspan`Talvez já em andamento @BHUVANSH855 assumiu há 96 dias. Abertaarea: material/table docs P4
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
angular/components#33455 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de angular/components
Issues semelhantes
-
e2e-failure ready-to-code
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
redhat-developer/rhdh-plugin-export-overlays#4460 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 77/100
Mantenedores costumam responder em até 1 dia
-
docs(api): openapi.yaml still documents gif-tools optimize colors as 2-256 instead of 2, 4, 16, 256Abertaarea: backend documentation priority: low
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
snapotter-hq/SnapOtter#2919 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 77/100
obsidianmd/pele#39 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
biomejs/biome#12475 · 1 comentário ·
Mantenedores costumam responder em até 1 dia