Skip to content

Commit

Permalink
[TextFields] Add identity check in -setTextColor: in MDCTextField (#9480
Browse files Browse the repository at this point in the history
)

This PR adds an identity check in `-setTextColor:` in MDCTextField. This identity check short circuits an infinite loop triggered by `-setTextColor:` under certain mysterious circumstances involving the MDCTextField layout pass and MDCFlexibleHeaderView KVO stuff surrounding safeAreaInset changes. I don't fully understand what's going on tbh :)

The internal bug ([b/148159587](http://b/148159587)) has links to before and after gifs in the comments.

Closes #9470

### Update: The internal client who reported the bug was unable to reproduce it with these changes.
  • Loading branch information
andrewoverton committed Jan 24, 2020
1 parent c95a444 commit 7a48d39
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions components/TextFields/src/MDCTextField.m
Expand Up @@ -333,8 +333,13 @@ - (UIColor *)textColor {
}

- (void)setTextColor:(UIColor *)textColor {
[super setTextColor:textColor];
_fundament.textColor = textColor;
// This identity check was added in
// https://github.com/material-components/material-components-ios/pull/9480 in response to
// b/148159587
if (textColor != self.textColor) {
[super setTextColor:textColor];
_fundament.textColor = textColor;
}
}

- (UIEdgeInsets)textInsets {
Expand Down

0 comments on commit 7a48d39

Please sign in to comment.