Skip to content

Commit a046e54

Browse files
committed
fix: rebase with latest main
1 parent 7646362 commit a046e54

3 files changed

Lines changed: 21 additions & 7 deletions

File tree

ios/EnrichedTextInputView.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ - (void)setupTextView {
251251
textView.layoutManager.input = self;
252252
textView.autoresizingMask =
253253
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
254-
textView.adjustsFontForContentSizeCategory = YES;
254+
textView.adjustsFontForContentSizeCategory = YES;
255255
}
256256

257257
// MARK: - Props
@@ -1731,7 +1731,7 @@ - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
17311731
defaultTypingAttributes = newTypingAttrs;
17321732
textView.typingAttributes = defaultTypingAttributes;
17331733

1734-
[self refreshPlaceholderLabelStyles];
1734+
[textView refreshPlaceholder];
17351735

17361736
NSRange prevSelectedRange = textView.selectedRange;
17371737

ios/inputTextView/InputTextView.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
@property(nonatomic, copy, nullable) NSString *placeholderText;
77
@property(nonatomic, strong, nullable) UIColor *placeholderColor;
88
- (void)updatePlaceholderVisibility;
9+
- (void)refreshPlaceholder;
910
@end

ios/inputTextView/InputTextView.mm

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ - (instancetype)initWithFrame:(CGRect)frame {
1414
_placeholderView = [[UILabel alloc] initWithFrame:self.bounds];
1515
_placeholderView.isAccessibilityElement = NO;
1616
_placeholderView.numberOfLines = 0;
17+
_placeholderView.adjustsFontForContentSizeCategory = YES;
1718
[self addSubview:_placeholderView];
1819

1920
self.textContainer.lineFragmentPadding = 0;
@@ -189,19 +190,31 @@ - (void)setAttributedText:(NSAttributedString *)attributedText {
189190
}
190191

191192
- (void)setPlaceholderText:(NSString *)newPlaceholderText {
193+
_placeholderText = newPlaceholderText;
194+
[self refreshPlaceholder];
195+
}
196+
197+
- (void)refreshPlaceholder {
192198
EnrichedTextInputView *typedInput = (EnrichedTextInputView *)_input;
193199
if (typedInput == nullptr) {
194200
return;
195201
}
196-
_placeholderText = newPlaceholderText;
197-
BOOL hasPlaceholder = newPlaceholderText && newPlaceholderText.length > 0;
198-
NSString *placeholderText = hasPlaceholder ? newPlaceholderText : @"";
202+
199203
NSMutableDictionary *attributes =
200204
[typedInput->defaultTypingAttributes mutableCopy];
201-
attributes[NSForegroundColorAttributeName] = _placeholderColor;
205+
206+
if (_placeholderColor) {
207+
attributes[NSForegroundColorAttributeName] = _placeholderColor;
208+
}
209+
210+
NSString *placeholder = _placeholderText ?: @"";
211+
202212
_placeholderView.attributedText =
203-
[[NSAttributedString alloc] initWithString:placeholderText
213+
[[NSAttributedString alloc] initWithString:placeholder
204214
attributes:attributes];
215+
216+
[self updatePlaceholderVisibility];
217+
205218
[self setNeedsLayout];
206219
}
207220

0 commit comments

Comments
 (0)