Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(material/chips): chip input with autocomplete has both the selected and the suggested values added #28874

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/material/chips/chip-input.ts
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {BACKSPACE, hasModifierKey} from '@angular/cdk/keycodes';
import {BACKSPACE, ENTER, hasModifierKey} from '@angular/cdk/keycodes';
import {
AfterContentInit,
Directive,
Expand Down Expand Up @@ -167,6 +167,10 @@ export class MatChipInput implements MatChipTextControl, AfterContentInit, OnCha
this._chipGrid._focusLastChip();
event.preventDefault();
return;
} else if (event.keyCode === ENTER) {
// Prevent adding both the search string and the selected suggestion
event.preventDefault();
return;
} else {
this._focusLastChipOnBackspace = false;
}
Expand Down