|
7 | 7 | */
|
8 | 8 |
|
9 | 9 | import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';
|
10 |
| -import {Directive, ElementRef, EventEmitter, Inject, Input, OnChanges, Output} from '@angular/core'; |
11 | 10 | import {hasModifierKey, TAB} from '@angular/cdk/keycodes';
|
12 |
| -import {MAT_CHIPS_DEFAULT_OPTIONS, MatChipsDefaultOptions} from './chip-default-options'; |
| 11 | +import {Directive, ElementRef, EventEmitter, Inject, Input, OnChanges, Output} from '@angular/core'; |
| 12 | +import {MatChipsDefaultOptions, MAT_CHIPS_DEFAULT_OPTIONS} from './chip-default-options'; |
13 | 13 | import {MatChipGrid} from './chip-grid';
|
14 | 14 | import {MatChipTextControl} from './chip-text-control';
|
15 | 15 |
|
@@ -74,7 +74,8 @@ export class MatChipInput implements MatChipTextControl, OnChanges {
|
74 | 74 | * Defaults to `[ENTER]`.
|
75 | 75 | */
|
76 | 76 | @Input('matChipInputSeparatorKeyCodes')
|
77 |
| - separatorKeyCodes: number[] | Set<number> = this._defaultOptions.separatorKeyCodes; |
| 77 | + separatorKeyCodes: readonly number[] | ReadonlySet<number> = |
| 78 | + this._defaultOptions.separatorKeyCodes; |
78 | 79 |
|
79 | 80 | /** Emitted when a chip is to be added. */
|
80 | 81 | @Output('matChipInputTokenEnd')
|
@@ -163,13 +164,7 @@ export class MatChipInput implements MatChipTextControl, OnChanges {
|
163 | 164 |
|
164 | 165 | /** Checks whether a keycode is one of the configured separators. */
|
165 | 166 | private _isSeparatorKey(event: KeyboardEvent) {
|
166 |
| - if (hasModifierKey(event)) { |
167 |
| - return false; |
168 |
| - } |
169 |
| - |
170 |
| - const separators = this.separatorKeyCodes; |
171 |
| - const keyCode = event.keyCode; |
172 |
| - return Array.isArray(separators) ? separators.indexOf(keyCode) > -1 : separators.has(keyCode); |
| 167 | + return !hasModifierKey(event) && new Set(this.separatorKeyCodes).has(event.keyCode); |
173 | 168 | }
|
174 | 169 |
|
175 | 170 | static ngAcceptInputType_addOnBlur: BooleanInput;
|
|
0 commit comments