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

feat(material-experimental/mdc-checkbox): add default options #17578

Merged
merged 2 commits into from
Nov 4, 2019

Conversation

andrewseguin
Copy link
Contributor

Follow-up to legacy checkbox's options implementation, PR #17473 - changes and tests are essentially copy/paste to maintain parity between the two

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 1, 2019
@andrewseguin andrewseguin requested a review from jelbourn November 1, 2019 20:21
@andrewseguin andrewseguin added pr: merge safe target: patch This PR is targeted for the next patch release labels Nov 1, 2019
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

this.tabIndex = parseInt(tabIndex) || 0;
this._checkboxFoundation = new MDCCheckboxFoundation(this._checkboxAdapter);

this._options = this._options || {};
Copy link
Member

Choose a reason for hiding this comment

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

You're only using the options in the constructor so you don't need to create a property for them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, though it does make it a little nicer for the following lines where I directly access this._options instead of adding an if(this._options) { ... } check before them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use default parameters on constructors that get DI'd? i.e.:
@Optional() @Inject(MAT_CHECKBOX_DEFAULT_OPTIONS) private _options: MatCheckboxDefaultOptions = {}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately not, Angular will inject null if it's not provided: https://stackblitz.com/edit/angular-euxmcx?file=src/app/app.component.ts

this.color = this._options.color;
}

// TODO: Remove this after the `_clickAction` parameter is removed as an injection parameter.
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 have a @breaking-change 10.0.0 so we can catch it in the breaking changes script while doing the cleanup.

@andrewseguin andrewseguin added the action: merge The PR is ready for merge by the caretaker label Nov 4, 2019
@andrewseguin andrewseguin merged commit 4cc69d2 into angular:master Nov 4, 2019
@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 Dec 5, 2019
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 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