Skip to content

Commit 5dfc363

Browse files
lekhmanruscrisbeto
authored andcommitted
docs(material/chips): add only active autocomplete option on selection (#32208)
* fix(material/chips): add only active autocomplete option on selection close #32204, #13574 * docs(material/chips): add only active autocomplete option on selection close #32204, #13574 (cherry picked from commit 943e1e3)
1 parent f61f2f1 commit 5dfc363

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/components-examples/material/chips/chips-autocomplete/chips-autocomplete-example.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ import {LiveAnnouncer} from '@angular/cdk/a11y';
22
import {COMMA, ENTER} from '@angular/cdk/keycodes';
33
import {ChangeDetectionStrategy, Component, computed, inject, model, signal} from '@angular/core';
44
import {FormsModule} from '@angular/forms';
5-
import {MatAutocompleteModule, MatAutocompleteSelectedEvent} from '@angular/material/autocomplete';
6-
import {MatChipInputEvent, MatChipsModule} from '@angular/material/chips';
5+
import {
6+
MatAutocompleteModule,
7+
type MatAutocompleteSelectedEvent,
8+
} from '@angular/material/autocomplete';
9+
import {type MatChipInputEvent, MatChipsModule} from '@angular/material/chips';
710
import {MatFormFieldModule} from '@angular/material/form-field';
811
import {MatIconModule} from '@angular/material/icon';
912

@@ -14,7 +17,9 @@ import {MatIconModule} from '@angular/material/icon';
1417
selector: 'chips-autocomplete-example',
1518
templateUrl: 'chips-autocomplete-example.html',
1619
styleUrl: 'chips-autocomplete-example.css',
17-
imports: [MatFormFieldModule, MatChipsModule, MatIconModule, MatAutocompleteModule, FormsModule],
20+
// Make sure to import `MatAutocompleteModule` before `MatChipsModule` to prevent adding typed
21+
// text when autocomplete option is selected via keyboard).
22+
imports: [MatFormFieldModule, MatAutocompleteModule, MatChipsModule, MatIconModule, FormsModule],
1823
changeDetection: ChangeDetectionStrategy.OnPush,
1924
})
2025
export class ChipsAutocompleteExample {

src/material/chips/chips.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ Users can press delete to remove a chip. Pressing delete triggers the `removed`
6565

6666
A `<mat-chip-grid>` can be combined with `<mat-autocomplete>` to enable free-form chip input with suggestions.
6767

68+
> _Please note: when using `MatChipsModule` together with `MatAutocompleteModule`, the order in which modules are imported matters._
69+
> _To ensure correct behavior (e.g., preventing adding typed text when autocomplete option is selected via keyboard), make sure to import `MatAutocompleteModule` before `MatChipsModule`._
70+
6871
<!-- example(chips-autocomplete) -->
6972

7073
### Icons
@@ -141,7 +144,7 @@ The chips components support 3 user interaction patterns, each with its own cont
141144

142145
`<mat-chip-grid>` and `<mat-chip-row>` : These elements implement a grid accessibility pattern. Use them as part of a free form input that allows users to enter text to add chips.
143146

144-
Note : be sure to have the input element be a sibling of mat-chip-grid to ensure accessibility of the input element by accessibility devices such as Voice Control. It is also recommended to apply an appropriate `aria-label` to the input to optimize accessibility of the input.
147+
> _Please note: be sure to have the input element be a sibling of `mat-chip-grid` to ensure accessibility of the input element by accessibility devices such as Voice Control. It is also recommended to apply an appropriate `aria-label` to the input to optimize accessibility of the input._
145148
146149
```html
147150
<mat-form-field>

0 commit comments

Comments
 (0)