Skip to content
Permalink
Browse files

[TextFields] Corrects obscure bug of height. (#4297)

  • Loading branch information
willlarche committed May 29, 2018
1 parent 520ac15 commit 776a40e409a1c779cbfd6872952e8a462c34ba09
Showing with 24 additions and 0 deletions.
  1. +24 −0 components/TextFields/src/MDCMultilineTextField.m
@@ -51,6 +51,8 @@ @interface MDCMultilineTextField () {

@property(nonatomic, assign, getter=isEditing) BOOL editing;

@property(nonatomic, assign) CGFloat textViewWidth;

@property(nonatomic, strong) MDCTextInputCommonFundament *fundament;

@property(nonatomic, strong) NSLayoutConstraint *textViewBottomSuperviewBottom;
@@ -329,6 +331,8 @@ - (void)layoutSubviews {
if ([self.positioningDelegate respondsToSelector:@selector(textInputDidLayoutSubviews)]) {
[self.positioningDelegate textInputDidLayoutSubviews];
}

[self updateIntrinsicSizeFromTextView];
}

- (void)updateConstraints {
@@ -400,7 +404,9 @@ - (void)updateConstraints {
[self.fundament updateConstraintsOfInput];

[self updateTrailingViewLayout];
[self updateIntrinsicSizeFromTextView];

// This must always be the last message in this method.
[super updateConstraints];
}

@@ -413,6 +419,24 @@ - (CGFloat)estimatedTextViewLineHeight {
return MDCCeil(self.textView.font.lineHeight * scale) / scale;
}

- (void)updateIntrinsicSizeFromTextView {
if ([self textViewWidthDidChange]) {
[self invalidateIntrinsicContentSize];
}
}

- (BOOL)textViewWidthDidChange {
BOOL widthDidChange = NO;
CGFloat currentTextViewWidth = CGRectGetWidth(self.textView.bounds);

if (self.textViewWidth != currentTextViewWidth) {
widthDidChange = YES;
}
self.textViewWidth = currentTextViewWidth;

return widthDidChange;
}

#pragma mark - Touch (UIView)

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {

0 comments on commit 776a40e

Please sign in to comment.
You can’t perform that action at this time.