Open
Description
Overview
I've identified several inconsistencies in the TextInput component's auto-growing behavior when used with KeyboardAwareScrollView, affecting both iOS and Android platforms. These issues vary depending on prop configurations and component wrapping.
Detailed Findings
Base Case (No value/onChangeText props)
- TextInput doesn't auto-grow regardless of multiline prop
- Height only respects minHeight or height style properties
- Behavior consistent across iOS and Android
kas-without-props.mp4
With value and onChangeText props
- Height Behavior:
- Respects minHeight and auto-grows after reaching minimum
- Fixed height when explicitly set; no auto-growing beyond specified height
- Scrolling Issues:
-
Noticeable "jumpy" behavior when:
- Cursor reaches end of last line
- First character on new line triggers internal scroll
- Second character triggers height auto-grow and ScrollView adjustment
kas-with-props.mp4
- Less noticeable when cursor is in middle of content
TextInput Wrapped in View
- Auto-growing works without value/onChangeText props
- Platform-specific differences:
- iOS: Minimal jumping, hardly noticeable
- Android: Jumping behavior persists, similar to non-wrapped version
kas-with-views.mp4
Comparison with React Native's ScrollView
Native ScrollView demonstrates superior behavior:
- Consistent auto-growing without requiring value/onChangeText props
- Significantly reduced jumping compared to KeyboardAwareScrollView with View wrapper
rns-without-props-and-views.mp4
Code Examples
I've included three implementation scenarios to demonstrate these issues and one with react native ScrollView:
- Basic Implementation
<KeyboardAwareScrollView>
<TextInput
multiline
placeholder="TextInput"
placeholderTextColor="black"
style={styles.textInput}
/>
</KeyboardAwareScrollView>
- With Props
<KeyboardAwareScrollView>
<TextInput
multiline
value={value}
onChangeText={onChange}
placeholder="TextInput"
placeholderTextColor="black"
style={styles.textInput}
/>
</KeyboardAwareScrollView>
- With View Wrapper
<KeyboardAwareScrollView>
<View>
<TextInput
multiline
placeholder="TextInput"
placeholderTextColor="black"
style={styles.textInput}
/>
</View>
</KeyboardAwareScrollView>
- React Native ScrollView
<ScrollView>
<TextInput
multiline
placeholder="TextInput"
placeholderTextColor="black"
style={styles.textInput}
/>
</ScrollView>
Devices tested:
Android:
- Physical: Redmi Note 10 Pro
- Emulator: Pixel_8_API_35
iOS:
- Physical: iPhone 15
Development Environment:
- Desktop OS: MacOS Sonoma
Environment:
- expo: "~52.0.28"
- expo: "~52.0.28"
- react-native: "0.76.6"
- react-native-keyboard-controller: "^1.16.1"