Skip to content
Open
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
11 changes: 7 additions & 4 deletions src/material/chips/chip-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* found in the LICENSE file at https://angular.dev/license
*/

import {BACKSPACE, hasModifierKey} from '@angular/cdk/keycodes';
import {_IdGenerator} from '@angular/cdk/a11y';
import {BACKSPACE, ENTER, hasModifierKey} from '@angular/cdk/keycodes';
import {
Directive,
ElementRef,
Expand All @@ -18,11 +19,10 @@ import {
booleanAttribute,
inject,
} from '@angular/core';
import {_IdGenerator} from '@angular/cdk/a11y';
import {MatFormField, MAT_FORM_FIELD} from '@angular/material/form-field';
import {MatChipsDefaultOptions, MAT_CHIPS_DEFAULT_OPTIONS} from './tokens';
import {MAT_FORM_FIELD, MatFormField} from '@angular/material/form-field';
import {MatChipGrid} from './chip-grid';
import {MatChipTextControl} from './chip-text-control';
import {MAT_CHIPS_DEFAULT_OPTIONS, MatChipsDefaultOptions} from './tokens';

/** Represents an input event on a `matChipInput`. */
export interface MatChipInputEvent {
Expand Down Expand Up @@ -156,6 +156,9 @@ export class MatChipInput implements MatChipTextControl, OnChanges, OnDestroy {
this._chipGrid._focusLastChip();
}
event.preventDefault();
} else if (event.keyCode === ENTER) {
// Prevent adding both the search string and the selected suggestion
event.preventDefault();
} else {
this._emitChipEnd(event);
}
Expand Down
Loading