Skip to content

Commit 316e984

Browse files
authored
fix(iOS): default value scroll (#465)
# Summary Fixes iOS input scrolling when provided default value is too long to fit maximum input height. ## Test Plan - Enter longer `defaultValue`, for the example app below should be enough ```tsx defaultValue={ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec suscipit auctor dui, at efficitur velit. Donec a semper nisl. Sed id metus ac enim commodo efficitur. Donec eget ligula a enim efficitur efficitur. Donec sed felis eget nunc convallis varius. Curabitur in mi ut nisl tincidunt commodo. In eleifend, enim in facilisis commodo, odio nisl faucibus enim, sed efficitur nisi nisl et nunc. Proin ac sem ut ipsum varius fringilla. Donec eget est a sapien efficitur convallis. Donec ac odio ac justo efficitur fermentum. Donec vel nibh a felis efficitur cursus.' } ``` - Refresh the app - Notice that input is scrollable ## Screenshots / Videos https://github.com/user-attachments/assets/fe2ec476-6ddf-4c8d-b76a-2f9ea60d8ed8 ## Compatibility | OS | Implemented | | ------- | :---------: | | iOS | ✅ | | Android | ❌ |
1 parent 884ea5e commit 316e984

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

ios/EnrichedTextInputView.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ NS_ASSUME_NONNULL_BEGIN
4040
- (void)emitOnMentionEvent:(NSString *)indicator text:(nullable NSString *)text;
4141
- (void)emitOnPasteImagesEvent:(NSArray<NSDictionary *> *)images;
4242
- (void)anyTextMayHaveBeenModified;
43+
- (void)scheduleRelayoutIfNeeded;
4344
- (BOOL)handleStyleBlocksAndConflicts:(StyleType)type range:(NSRange)range;
4445
- (NSArray<NSNumber *> *)getPresentStyleTypesFrom:(NSArray<NSNumber *> *)types
4546
range:(NSRange)range;

ios/inputTextView/InputTextView.mm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66

77
@implementation InputTextView
88

9+
- (void)layoutSubviews {
10+
[super layoutSubviews];
11+
// UITextView resets contentSize during its own layout pass (triggered when
12+
// the frame is set on first mount). Re-schedule a relayout so our explicit
13+
// contentSize is applied after UITextView finishes its internal layout.
14+
EnrichedTextInputView *input = (EnrichedTextInputView *)_input;
15+
if (input != nil) {
16+
[input scheduleRelayoutIfNeeded];
17+
}
18+
}
19+
920
- (void)copy:(id)sender {
1021
EnrichedTextInputView *typedInput = (EnrichedTextInputView *)_input;
1122
if (typedInput == nullptr) {

0 commit comments

Comments
 (0)