Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

bug(aria/combobox): ComboboxPopup throws NG0950 when destroyed before its first change detection

Đang mở Phù hợp với người mới
#33,972 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@lazerg đang làm issue này rồi.

Từ ngày 20/10/2026.

  • #33974 của @lazerg — đang mở

Đá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ả

area: aria/combobox gemini-triaged
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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của angular/components

Tất cả issue của angular/components

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.