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

chore(input): switch to OnPush change detection #5692

Merged
merged 2 commits into from Jul 25, 2017

Conversation

crisbeto
Copy link
Member

Switches the MdInputContainer to OnPush change detection and sorts out the various change detection-related issues.

Relates to #5035.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jul 11, 2017
@jelbourn jelbourn requested a review from mmalerba July 11, 2017 22:19
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

Just one comment from me, @mmalerba should take a look


/** Whether the element is focused or not. */
focused = false;

/** Sets the aria-describedby attribute on the input for improved a11y. */
ariaDescribedby: string;

/** Stream that emits whenever one of the input states changes. */
Copy link
Member

Choose a reason for hiding this comment

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

Expand this comment to include why this is necessary at all?


_onBlur() { this.focused = false; }
ngDoCheck() {
if (this._ngControl) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah very cool, this is what I was talking about when I said forms doesn't always give us a way to know when we need to update, but this is a cool workaround :)

Copy link
Contributor

@willshowell willshowell left a comment

Choose a reason for hiding this comment

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

Happy to close #5660 since it looks like this takes care of that 👍

if (this._ngControl) {
// We need to re-evaluate this on every change detection cycle, because there are some
// error triggers that we can't subscribe to (e.g. parent form submissions). This means
// that whatever logic is in here has to be super lean or we risk destroying the performance.
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to also add a note to the Custom Error Matcher section of input.md that mentions this?

Note: An input's error state must be calculated every change detection cycle, so it is important to keep the logic in your error state matcher very lean or you risk destroying performance.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure there is. FWIW, the code currently in master will be called even more times per change detection cycle since we have the _isErrorState in multiple places.

@crisbeto
Copy link
Member Author

Addressed the feedback @jelbourn.

@willshowell if nothing else, #5660 still provides some value by adding the extra unit test.

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Jul 12, 2017
@jelbourn
Copy link
Member

@crisbeto looks to be a few lint errors

@kara kara added pr: needs rebase and removed action: merge The PR is ready for merge by the caretaker labels Jul 20, 2017
@kara kara assigned crisbeto and unassigned jelbourn and mmalerba Jul 20, 2017
@kara
Copy link
Contributor

kara commented Jul 20, 2017

@crisbeto Rebase?

Switches the `MdInputContainer` to `OnPush` change detection and sorts out the various change detection-related issues.

Relates to angular#5035.
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker and removed pr: needs rebase labels Jul 20, 2017
@crisbeto
Copy link
Member Author

Rebased.

@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 Sep 6, 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants