Skip to content

Commit 73c1912

Browse files
authored
docs(aria/combobox): update JSDoc (#33271)
1 parent f2c6e4d commit 73c1912

1 file changed

Lines changed: 26 additions & 10 deletions

File tree

src/aria/combobox/combobox.ts

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,37 @@ import {DeferredContentAware, ComboboxPattern, tabIndexTransform} from '@angular
2323
import type {ComboboxPopup} from './combobox-popup';
2424

2525
/**
26-
* The container element that wraps a combobox input and popup, and orchestrates its behavior.
26+
* A directive that coordinates a combobox trigger element and its associated popup widget.
2727
*
28-
* The `ngCombobox` directive is the main entry point for creating a combobox and customizing its
29-
* behavior. It coordinates the interactions between the input and the popup.
28+
* The `ngCombobox` directive is applied directly to the interactive trigger element, which can be
29+
* either an editable `<input>` (for search/autocomplete behaviors) or a non-editable element like
30+
* a `<div>` (for custom select dropdowns). It manages focus and expansion states, coordinates autocomplete
31+
* suggestions (if editable), and forwards navigation keys down into the active popup.
3032
*
33+
* ### Example 1: Editable Autocomplete Input
3134
* ```html
32-
* <div ngCombobox [(expanded)]="expanded">
33-
* <input ngComboboxInput />
35+
* <input ngCombobox #combobox="ngCombobox" [(value)]="searchQuery" [(expanded)]="isExpanded" />
3436
*
35-
* <ng-template ngComboboxPopup>
36-
* <div ngComboboxWidget>
37-
* <!-- ... options ... -->
38-
* </div>
39-
* </ng-template>
37+
* <ng-template ngComboboxPopup [combobox]="combobox">
38+
* <div ngComboboxWidget #listbox="ngListbox" ngListbox [(value)]="selectedValues" [activeDescendant]="listbox.activeDescendant()">
39+
* <div ngOption value="first">First Option</div>
40+
* <div ngOption value="second">Second Option</div>
41+
* </div>
42+
* </ng-template>
43+
* ```
44+
*
45+
* ### Example 2: Non-Editable Custom Select Dropdown
46+
* ```html
47+
* <div ngCombobox #combobox="ngCombobox" [(expanded)]="isExpanded" class="select-trigger">
48+
* {{selectedValue}}
4049
* </div>
50+
*
51+
* <ng-template ngComboboxPopup [combobox]="combobox">
52+
* <div ngComboboxWidget #listbox="ngListbox" ngListbox [(value)]="selectedValues" [activeDescendant]="listbox.activeDescendant()">
53+
* <div ngOption value="first">First Option</div>
54+
* <div ngOption value="second">Second Option</div>
55+
* </div>
56+
* </ng-template>
4157
* ```
4258
*/
4359
@Directive({

0 commit comments

Comments
 (0)