Skip to content

docs(checkbox): add indeterminate and disabled checkbox examples #18987

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

Merged
merged 2 commits into from
Apr 17, 2020

Conversation

livvielin
Copy link
Contributor

Screen Shot 2020-04-03 at 5 04 07 PM

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Apr 4, 2020
Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

Looks like there's a lint warning as well.

[(ngModel)]="task.completed"
[checked]="allComplete()"
[indeterminate]="someComplete()"
(change)="setAll($event.checked)">
Copy link
Member

Choose a reason for hiding this comment

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

Since we're using ngModel above, it might be better to use the ngModelChange event here for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't quite work, since the ngModel was task.completed and it's not looking at the right object. Instead, I removed ngModel and use change. Does that seem ok?

if (this.task.subtasks == null) {
return false;
}
return this.task.subtasks.filter(t => t.completed).length > 0 && !this.allComplete();
Copy link
Member

Choose a reason for hiding this comment

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

This is definitely the cleaner way to do it, but I'm not sure whether it's the best in terms of performance, because this method and allComplete will be invoked on every change detection run. It might be better to have this in a boolean property and recalculate it once when a value has changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to make allComplete a boolean, and changed the method to updateAllComplete, which sets allComplete when subtasks change and when calling setAll. Was that along the lines of what you were thinking?

Copy link
Contributor Author

@livvielin livvielin left a comment

Choose a reason for hiding this comment

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

Also fixed the lint error

[(ngModel)]="task.completed"
[checked]="allComplete()"
[indeterminate]="someComplete()"
(change)="setAll($event.checked)">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't quite work, since the ngModel was task.completed and it's not looking at the right object. Instead, I removed ngModel and use change. Does that seem ok?

if (this.task.subtasks == null) {
return false;
}
return this.task.subtasks.filter(t => t.completed).length > 0 && !this.allComplete();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to make allComplete a boolean, and changed the method to updateAllComplete, which sets allComplete when subtasks change and when calling setAll. Was that along the lines of what you were thinking?

Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

LGTM

@crisbeto crisbeto added docs This issue is related to documentation lgtm action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Apr 11, 2020
@andrewseguin andrewseguin merged commit 68eaaf6 into angular:master Apr 17, 2020
andrewseguin pushed a commit that referenced this pull request Apr 17, 2020
)

* docs(checkbox): add indeterminate and disabled checkbox examples

* Make fixes

(cherry picked from commit 68eaaf6)
soro-google pushed a commit to soro-google/components that referenced this pull request Apr 24, 2020
…ular#18987)

* docs(checkbox): add indeterminate and disabled checkbox examples

* Make fixes
@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 May 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement docs This issue is related to documentation target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants