Skip to content

Commit

Permalink
Revert "Revert "feat(material/chips): prevent chips from being delete… (
Browse files Browse the repository at this point in the history
angular#22235)

* Revert "Revert "feat(material/chips): prevent chips from being deleted when user holds backspace (angular#19700)""

This is a roll-forward of the original PR. We will need to resolve the
issues in Google's code base that caused it to be reverted before
merging again.

This reverts commit 4381b8e.

* fixup! Revert "Revert "feat(material/chips): prevent chips from being deleted when user holds backspace (angular#19700)""

* fixup! Revert "Revert "feat(material/chips): prevent chips from being deleted when user holds backspace (angular#19700)""
  • Loading branch information
mmalerba committed Mar 16, 2021
1 parent 662b751 commit d11e293
Show file tree
Hide file tree
Showing 12 changed files with 462 additions and 332 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,15 @@ export class ChipsAutocompleteExample {
}

add(event: MatChipInputEvent): void {
const input = event.input;
const value = event.value;
const value = (event.value || '').trim();

// Add our fruit
if ((value || '').trim()) {
this.fruits.push(value.trim());
if (value) {
this.fruits.push(value);
}

// Reset the input value
if (input) {
input.value = '';
}
// Clear the input value
event.chipInput!.clear();

this.fruitCtrl.setValue(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,15 @@ export class ChipsInputExample {
];

add(event: MatChipInputEvent): void {
const input = event.input;
const value = event.value;
const value = (event.value || '').trim();

// Add our fruit
if ((value || '').trim()) {
this.fruits.push({name: value.trim()});
if (value) {
this.fruits.push({name: value});
}

// Reset the input value
if (input) {
input.value = '';
}
// Clear the input value
event.chipInput!.clear();
}

remove(fruit: Fruit): void {
Expand Down
13 changes: 5 additions & 8 deletions src/dev-app/chips/chips-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {Component} from '@angular/core';
import {MatChipInputEvent} from '@angular/material/chips';
import {ThemePalette} from '@angular/material/core';


export interface Person {
name: string;
}
Expand Down Expand Up @@ -61,17 +60,15 @@ export class ChipsDemo {
}

add(event: MatChipInputEvent): void {
const {input, value} = event;
const value = (event.value || '').trim();

// Add our person
if ((value || '').trim()) {
this.people.push({ name: value.trim() });
if (value) {
this.people.push({ name: value });
}

// Reset the input value
if (input) {
input.value = '';
}
// Clear the input value
event.chipInput!.clear();
}

remove(person: Person): void {
Expand Down
12 changes: 5 additions & 7 deletions src/dev-app/mdc-chips/mdc-chips-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,15 @@ export class MdcChipsDemo {
}

add(event: MatChipInputEvent): void {
const {input, value} = event;
const value = (event.value || '').trim();

// Add our person
if ((value || '').trim()) {
this.people.push({ name: value.trim() });
if (value) {
this.people.push({ name: value });
}

// Reset the input value
if (input) {
input.value = '';
}
// Clear the input value
event.chipInput!.clear();
}

remove(person: Person): void {
Expand Down

0 comments on commit d11e293

Please sign in to comment.