fix focus on dialog open

This commit is contained in:
ammarahm-ed
2020-03-02 12:12:23 +05:00
parent 437f7ade9a
commit 17618d6d65
2 changed files with 7 additions and 4 deletions

View File

@@ -206,9 +206,7 @@ export class AddNotebookDialog extends React.Component {
animated animated
animationType="fade" animationType="fade"
onShow={() => { onShow={() => {
setTimeout(() => {
this.titleRef.focus(); this.titleRef.focus();
}, 300);
}} }}
onRequestClose={this.close}> onRequestClose={this.close}>
<KeyboardAvoidingView <KeyboardAvoidingView

View File

@@ -1,4 +1,4 @@
import React from 'react'; import React, {createRef} from 'react';
import {Modal, Text, TouchableOpacity, View} from 'react-native'; import {Modal, Text, TouchableOpacity, View} from 'react-native';
import {TextInput} from 'react-native-gesture-handler'; import {TextInput} from 'react-native-gesture-handler';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
@@ -18,6 +18,7 @@ export class AddTopicDialog extends React.Component {
}; };
this.title; this.title;
this.titleRef = createRef();
} }
addNewTopic = async () => { addNewTopic = async () => {
@@ -52,6 +53,9 @@ export class AddTopicDialog extends React.Component {
animated animated
animationType="fade" animationType="fade"
transparent={true} transparent={true}
onShow={() => {
this.titleRef.current?.focus();
}}
onRequestClose={() => { onRequestClose={() => {
refs = []; refs = [];
this.close(); this.close();
@@ -102,6 +106,7 @@ export class AddTopicDialog extends React.Component {
</View> </View>
<TextInput <TextInput
ref={this.titleRef}
style={{ style={{
padding: pv, padding: pv,
borderWidth: 1.5, borderWidth: 1.5,