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

docs(material/chips): Describe how to use chips with forms #27780

Closed
wants to merge 1 commit into from

Conversation

fabi337
Copy link

@fabi337 fabi337 commented Sep 10, 2023

docs(material/chips): Describe how to use chips with forms

Describe how to use chips with forms

Fixes #22906

@google-cla
Copy link

google-cla bot commented Sep 10, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Describe how to use chips with forms

Fixes angular#22906
@fabi337 fabi337 changed the title fix(material/chips): docs docs(material/chips): Describe how to use chips with forms Sep 11, 2023
@mmalerba mmalerba requested review from crisbeto and removed request for andrewseguin September 26, 2023 20:22
@@ -0,0 +1,29 @@
<div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example isn't linked in the chips.md so it won't show up in the chips guide, it'll only be in the "Examples" tab. Is that intentional?

});

get fruits() {
return this.form.get('fruits');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove this getter and just use this.form.get('fruits') once at the top of add.


announcer = inject(LiveAnnouncer);

constructor() {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed.

return this.form.get('fruits');
}

announcer = inject(LiveAnnouncer);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be private.


const value = (event.value || '').trim();
// Add our fruit
if ((value || '').trim()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The (value || '').trim() here isn't necessary since it was done in the const above already.

// Add our fruit
if ((value || '').trim()) {
this.fruits.setValue([...this.fruits.value, {name: value.trim()} as Fruit]);
this.announcer.announce(`added ${event.value}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should "added" be capitalized?


add(event: MatChipInputEvent): void {
// Check if input is null
if (this.fruits == null) return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that we need the null check here since the fruit control is guaranteed to be defined.

// Edit existing fruit
const index = this.fruits?.value.indexOf(fruit);
if (index >= 0) {
let updatedFruits = [...this.fruits?.value];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that this needs to clone the array, it can update the name in place.

@crisbeto
Copy link
Member

Closing since there hasn't been any response to the feedback.

@crisbeto crisbeto closed this Feb 14, 2024
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docs-bug(MatChips): describe how to use chips with forms
2 participants