Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix focus on dialog open

ammarahm-ed17618d6d657e
diff --git a/apps/mobile/src/components/AddNotebookDialog/index.js b/apps/mobile/src/components/AddNotebookDialog/index.js
index 2b9f42cf6..8f0eb627a 100644
--- a/apps/mobile/src/components/AddNotebookDialog/index.js
+++ b/apps/mobile/src/components/AddNotebookDialog/index.js
@@ -206,9 +206,7 @@ export class AddNotebookDialog extends React.Component {
animated
animationType="fade"
onShow={() => {
- setTimeout(() => {
- this.titleRef.focus();
- }, 300);
+ this.titleRef.focus();
}}
onRequestClose={this.close}>
<KeyboardAvoidingView
diff --git a/apps/mobile/src/components/AddTopicDialog/index.js b/apps/mobile/src/components/AddTopicDialog/index.js
index ddd1364b0..2ed08774f 100644
--- a/apps/mobile/src/components/AddTopicDialog/index.js
+++ b/apps/mobile/src/components/AddTopicDialog/index.js
@@ -1,4 +1,4 @@
-import React from 'react';
+import React, {createRef} from 'react';
import {Modal, Text, TouchableOpacity, View} from 'react-native';
import {TextInput} from 'react-native-gesture-handler';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
@@ -18,6 +18,7 @@ export class AddTopicDialog extends React.Component {
};
this.title;
+ this.titleRef = createRef();
}
addNewTopic = async () => {
@@ -52,6 +53,9 @@ export class AddTopicDialog extends React.Component {
animated
animationType="fade"
transparent={true}
+ onShow={() => {
+ this.titleRef.current?.focus();
+ }}
onRequestClose={() => {
refs = [];
this.close();
@@ -102,6 +106,7 @@ export class AddTopicDialog extends React.Component {
</View>
<TextInput
+ ref={this.titleRef}
style={{
padding: pv,
borderWidth: 1.5,