React-native how to move screen up on textinput
In 2017 (RN 0.43) there is special component for this: KeyboardAvoidingView
How to move a view when the keyboard shows up in React Native?
How about go now with react-native KeyboardAvoidingView (official docs)
import {KeyboardAvoidingView} from 'react-native';
<KeyboardAvoidingView style={styles.container} behavior="padding" enabled>
... your UI ...
</KeyboardAvoidingView>;
Tested on iOS, for me works fine out of the box. For android consider adding parameter: android:windowSoftInputMode="adjustResize"
to your AndroidManifest.xml Automatically scroll the view up when keyboard is shown in react-native
I assume you are using this solution. I ran into the same problem and made some adjustments (see gist). I addressed both problems you describe. keyboardShouldPersistTaps solves your second problem.
I have not found the exact reason why the spacing works in Simulator but not on a real device. It has something to do with the timing. The original code sets a timeout on input focus and tries to scroll down after 50ms. Increasing this to for example 500ms makes it work on devices too, but I don't really like adding magic timeouts that I don't understand. I changed it, so onFocus I look up the element to scroll to and store a reference. When onKeyboardDidShow fires I use the reference.
Click TouchableOpacity while TextInput is focused
You are nesting a ScrollView
with a KeyboardAwareScrollView
.
You need to set the keyboardShouldPersistTaps
prop on the parent view as well. Consider the following code snippet from your snack.
<KeyboardAwareScrollView keyboardShouldPersistTaps='handled'>
<SafeAreaView style={styles.container}>
<ScrollView ref={scrollViewRef} onContentSizeChange={() => scrollViewRef.current.scrollToEnd({ animated: true })} keyboardShouldPersistTaps='handled'>
{steps.map(item => { return (<SingleAlgorithmStep key={item["Question"]} step={item} stepsDone={steps} clickedButtons={clickedButtons} algorithmJson={currentAlgorithmJson} actualizeSteps={(item) => updateSteps(item)} actualizeButtons={(item) => updateClickedButton(item)} />) })}
</ScrollView>
</SafeAreaView>
</KeyboardAwareScrollView>
This fixed the issue on my device. Losing TextInput's focus when Keyboard closes
Try keyboardShouldPersistTaps="handled"
as ScrollView
attribute. I tried the same on your given code and it worked. You can look more into the property details here.
Hope this will help!
Keyboard is not visible in the second time when reaching
You can use 'push' instead of 'navigate'. When navigating to the same interface componentWillMount/componentDidMount is not loading again. That may be the issue. Try with this.
Refer react navigation documentation.
React Navigation Documentation
Related Topics
JavaScript Request Fullscreen Is Unreliable
In Angular, How to Determine the Active Route
Why Is Window (And Unsafewindow) Not the Same from a Userscript as from a <Script> Tag
Ng-Model Does Not Update Controller Value
Pass Variables to JavaScript in Expressjs
What Is Firebase Firestore 'Reference' Data Type Good For
Convert CSV Data into JSON Format Using JavaScript
How to Initialize a JavaScript Date to Midnight
React Routing Works in Local MAChine But Not Heroku
Overriding Interface Property Type Defined in Typescript D.Ts File
Object Doesn't Support This Property or Method Rails Windows 64Bit
External Resource Not Being Loaded by Angularjs
What Is the JavaScript Mime Type for the Type Attribute of a Script Tag
What Is Ngdefaultcontrol in Angular
JavaScript String Array to Object
Omitting the Second Expression When Using the If-Else Shorthand