bug(aria/combobox): ComboboxPopup throws NG0950 when destroyed before its first change detection
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- angular, typescript
- Lĩnh vực
- accessibility, frontend
Hướng nghiên cứu
Bắt đầu tại src/aria/combobox/combobox-popup.ts, đặc biệt là ngOnDestroy, và kiểm tra việc đăng ký vòng đời cùng hành vi teardown của component. Tái hiện lỗi bằng bài kiểm thử được cung cấp, bài này tạo một fixture rồi hủy nó mà không chạy change detection. Hoàn tất khi teardown không còn đọc input bắt buộc chưa được thiết lập và bài kiểm thử chạy thành công.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- TypeScript
- Star
- 25k
- Fork
- 6.8k
- Merge trung bình
- 1 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 67
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của angular/components
-
bug(aria/combobox): keys pressed back to back are lost; only the last one reaches the popupCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởarea: aria/combobox gemini-triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
angular/components#33973 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug(material/sort): hover hint arrow on an unsorted header shows the active sort direction, not the resulting direction after click.Có thể đã có người làm @lekhmanrus đã nhận 12 ngày trước. Đang mởarea: material/sort P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
angular/components#33933 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug(mat-date-picker): month shown twice in date pickerCó thể đã có người làm @PreethiPantangi đã nhận 29 ngày trước. Đang mởarea: material/datepicker P4
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
angular/components#33763 · 2 bình luận · 3 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug in table.scss footer cell height: unset instead of footer row height unsetCó thể đã có người làm @minwookshin đã nhận 16 ngày trước. Đang mởarea: material/table P4
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
angular/components#33709 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
docs-bug(Table): Add example with `rowspan`Có thể đã có người làm @BHUVANSH855 đã nhận 97 ngày trước. Đang mởarea: material/table docs P4
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
angular/components#33455 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của angular/components
Issue tương tự
-
area: app type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
ExpidetGames/code-reviewer#585 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 83/100
module-federation/core#5205 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
LanternOps/breeze#9392 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
engine-rs P3 review-deferral wasm
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
maniator/verticopolis#1154 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày