Skip to content

Commit 425e208

Browse files
committed
Fix both floating & inline placeholders being shown when text is cleared
Fixes #20
1 parent 383be4f commit 425e208

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

MaterialTextField/MFTextField.m

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,9 @@ - (void)layoutPlaceholderLabelAnimated:(BOOL)animated
336336
{
337337
if (self.shouldShowPlaceholder) {
338338
[self updatePlaceholderColor];
339-
340-
if (self.placeholderIsHidden) {
341-
[self showPlaceholderLabelAnimated:animated];
342-
}
339+
[self showPlaceholderLabelAnimated:animated];
343340
}
344-
else if (!self.placeholderIsHidden) {
341+
else {
345342
[self hidePlaceholderLabelAnimated:animated];
346343
}
347344
}
@@ -423,6 +420,10 @@ - (void)showPlaceholderLabelAnimated:(BOOL)animated
423420
// Call setPlaceholder on super so placeholderAttributedString is not set to nil
424421
[super setPlaceholder:nil];
425422
}
423+
424+
if (!self.placeholderIsHidden) {
425+
return;
426+
}
426427

427428
if (animated && !self.placeholderIsAnimating) {
428429
[self.superview layoutIfNeeded];
@@ -452,6 +453,10 @@ - (void)showPlaceholderLabelAnimated:(BOOL)animated
452453

453454
- (void)hidePlaceholderLabelAnimated:(BOOL)animated
454455
{
456+
if (self.placeholderIsHidden) {
457+
return;
458+
}
459+
455460
CGFloat finalDistanceFromTop = CGRectGetMinY(self.textRect) / 2.0f;
456461

457462
if (self.placeholderAnimatesOnFocus) {

0 commit comments

Comments
 (0)