Skip to content

Commit ff0662d

Browse files
willshowelljelbourn
authored andcommitted
docs(autocomplete): cleanup overview doc (#6889)
- Removes broken spec link - General grammar and readability fixes - Add period to jsdoc for consistency
1 parent 6e4f90f commit ff0662d

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

src/lib/autocomplete/autocomplete.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
The autocomplete is a normal text input enhanced by a panel of suggested options.
2-
You can read more about autocompletes in the [Material Design spec](https://material.io/guidelines/components/text-fields.html#text-fields-auto-complete-text-field).
32

43
### Simple autocomplete
54

@@ -14,7 +13,7 @@ forms, you can read more about the subject in the [Angular documentation](https:
1413
*my-comp.html*
1514
```html
1615
<mat-form-field>
17-
<input type="text" matInput [formControl]="myControl">
16+
<input type="text" matInput [formControl]="myControl">
1817
</mat-form-field>
1918
```
2019

@@ -25,9 +24,9 @@ of the text input to be upon that option's selection.
2524
*my-comp.html*
2625
```html
2726
<mat-autocomplete>
28-
<mat-option *ngFor="let option of options" [value]="option">
29-
{{ option }}
30-
</mat-option>
27+
<mat-option *ngFor="let option of options" [value]="option">
28+
{{ option }}
29+
</mat-option>
3130
</mat-autocomplete>
3231
```
3332

@@ -38,13 +37,13 @@ to the input's `matAutocomplete` property.
3837
*my-comp.html*
3938
```html
4039
<mat-form-field>
41-
<input type="text" matInput [formControl]="myControl" [matAutocomplete]="auto">
40+
<input type="text" matInput [formControl]="myControl" [matAutocomplete]="auto">
4241
</mat-form-field>
4342

4443
<mat-autocomplete #auto="matAutocomplete">
45-
<mat-option *ngFor="let option of options" [value]="option">
46-
{{ option }}
47-
</mat-option>
44+
<mat-option *ngFor="let option of options" [value]="option">
45+
{{ option }}
46+
</mat-option>
4847
</mat-autocomplete>
4948
```
5049

@@ -55,17 +54,17 @@ to the input's `matAutocomplete` property.
5554
At this point, the autocomplete panel should be toggleable on focus and options should be
5655
selectable. But if we want our options to filter when we type, we need to add a custom filter.
5756

58-
You can filter the options in any way you like based on the text input*. Here we will perform a
57+
You can filter the options in any way you like based on the text input\*. Here we will perform a
5958
simple string test on the option value to see if it matches the input value, starting from the
60-
option's first letter. We already have access to the built-in `valueChanges` observable on the
59+
option's first letter. We already have access to the built-in `valueChanges` Observable on the
6160
`FormControl`, so we can simply map the text input's values to the suggested options by passing
62-
them through this filter. The resulting observable (`filteredOptions`) can be added to the
61+
them through this filter. The resulting Observable, `filteredOptions`, can be added to the
6362
template in place of the `options` property using the `async` pipe.
6463

6564
Below we are also priming our value change stream with `null` so that the options are filtered by
6665
that value on init (before there are any value changes).
6766

68-
*For optimal accessibility, you may want to consider adding text guidance on the page to explain
67+
\*For optimal accessibility, you may want to consider adding text guidance on the page to explain
6968
filter criteria. This is especially helpful for screenreader users if you're using a non-standard
7069
filter that doesn't limit matches to the beginning of the string.
7170

@@ -74,7 +73,7 @@ filter that doesn't limit matches to the beginning of the string.
7473
### Setting separate control and display values
7574

7675
If you want the option's control value (what is saved in the form) to be different than the option's
77-
display value (what is displayed in the actual text field), you'll need to set the `displayWith`
76+
display value (what is displayed in the text field), you'll need to set the `displayWith`
7877
property on your autocomplete element. A common use case for this might be if you want to save your
7978
data as an object, but display just one of the option's string properties.
8079

@@ -88,7 +87,7 @@ desired display value. Then bind it to the autocomplete's `displayWith` property
8887
- <kbd>UP_ARROW</kbd>: Previous option becomes active.
8988
- <kbd>ENTER</kbd>: Select currently active item.
9089

91-
#### Option groups
90+
### Option groups
9291
`mat-option` can be collected into groups using the `mat-optgroup` element:
9392

9493
```html
@@ -102,8 +101,8 @@ desired display value. Then bind it to the autocomplete's `displayWith` property
102101
```
103102

104103
### Accessibility
105-
The input for autocomplete without text or labels should be given a meaningful label via
104+
The input for an autocomplete without text or labels should be given a meaningful label via
106105
`aria-label` or `aria-labelledby`.
107106

108-
Autocomplete trigger is given `role="combobox"`. The trigger sets `aria-owns` to the autocomplete's
107+
The autocomplete trigger is given `role="combobox"`. The trigger sets `aria-owns` to the autocomplete's
109108
id, and sets `aria-activedescendant` to the active option's id.

src/lib/autocomplete/autocomplete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import {ActiveDescendantKeyManager} from '@angular/cdk/a11y';
3636
*/
3737
let _uniqueAutocompleteIdCounter = 0;
3838

39-
/** Event object that is emitted when an autocomplete option is selected */
39+
/** Event object that is emitted when an autocomplete option is selected. */
4040
export class MatAutocompleteSelectedEvent {
4141
constructor(
4242
/** Reference to the autocomplete panel that emitted the event. */

0 commit comments

Comments
 (0)