Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/aria/combobox/combobox-popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ import {COMBOBOX_POPUP} from './combobox-tokens';
export class ComboboxPopup implements OnInit, OnDestroy {
private readonly _deferredContent = inject(DeferredContent);

/** The combobox that the popup is registered with. */
private _registeredCombobox: Combobox | undefined;

/** The combobox that the popup belongs to. */
readonly combobox = input.required<Combobox>();

Expand All @@ -60,12 +63,13 @@ export class ComboboxPopup implements OnInit, OnDestroy {
});

ngOnInit() {
this.combobox()._registerPopup(this);
this._deferredContent.deferredContentAware.set(this.combobox());
this._registeredCombobox = this.combobox();
this._registeredCombobox._registerPopup(this);
this._deferredContent.deferredContentAware.set(this._registeredCombobox);
}

ngOnDestroy() {
this.combobox()._unregisterPopup();
this._registeredCombobox?._unregisterPopup();
}

/** Registers a widget with the popup. */
Expand Down
5 changes: 5 additions & 0 deletions src/aria/combobox/combobox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,11 @@ describe('Combobox', () => {
expect(comboboxElement.getAttribute('aria-expanded')).toBe('true');
});
});

it('should not throw when destroyed before the first change detection', () => {
const fixture = TestBed.createComponent(ComboboxListboxExample);
expect(() => fixture.destroy()).not.toThrow();
});
});

@Component({
Expand Down
Loading