fix editing.isFocused set to true outside editor

This commit is contained in:
ammarahm-ed
2021-01-14 14:55:33 +05:00
parent bdb90b0fca
commit 36f2bc4f9e
4 changed files with 16 additions and 9 deletions

View File

@@ -35,7 +35,6 @@ import {editorRef, tabBarRef} from './src/utils/Refs';
import {EditorWrapper} from './src/views/Editor/EditorWrapper'; import {EditorWrapper} from './src/views/Editor/EditorWrapper';
import {getIntent, getNote, post} from './src/views/Editor/Functions'; import {getIntent, getNote, post} from './src/views/Editor/Functions';
let {width, height} = Dimensions.get('window'); let {width, height} = Dimensions.get('window');
let movedAway = true;
let layoutTimer = null; let layoutTimer = null;
let currentTab = 0; let currentTab = 0;
@@ -43,7 +42,7 @@ let currentTab = 0;
const onChangeTab = async (obj) => { const onChangeTab = async (obj) => {
if (obj.i === 1) { if (obj.i === 1) {
eSendEvent(eCloseSideMenu); eSendEvent(eCloseSideMenu);
movedAway = false; editing.movedAway = false;
currentTab = 1; currentTab = 1;
activateKeepAwake(); activateKeepAwake();
eSendEvent('navigate'); eSendEvent('navigate');
@@ -58,7 +57,7 @@ const onChangeTab = async (obj) => {
if (getNote()?.locked) { if (getNote()?.locked) {
eSendEvent(eClearEditor); eSendEvent(eClearEditor);
} }
movedAway = true; editing.movedAway = true;
post('blur'); post('blur');
} }
editing.isFocused = false; editing.isFocused = false;
@@ -227,7 +226,7 @@ const AppStack = React.memo(
paddingHorizontal: 0, paddingHorizontal: 0,
}, },
}); });
if (!movedAway && current !== 'tablet') { if (!editing.movedAway && current !== 'tablet') {
tabBarRef.current?.goToPage(1); tabBarRef.current?.goToPage(1);
} }
} }

View File

@@ -57,7 +57,8 @@ export const editing = {
type: null, type: null,
}, },
isFocused:false, isFocused:false,
focusType:null focusType:null,
movedAway:true
}; };
export const selection = { export const selection = {
data: [], data: [],

View File

@@ -91,7 +91,9 @@ const EditorHeader = () => {
} }
await clearEditor(); await clearEditor();
Keyboard.removeListener('keyboardDidShow', () => { Keyboard.removeListener('keyboardDidShow', () => {
editing.isFocused = true; if (!editing.movedAway) {
editing.isFocused = true;
}
post('keyboard'); post('keyboard');
}); });
if (handleBack) { if (handleBack) {

View File

@@ -3,7 +3,7 @@ import {BackHandler, InteractionManager, Keyboard} from 'react-native';
import RNExitApp from 'react-native-exit-app'; import RNExitApp from 'react-native-exit-app';
import {simpleDialogEvent} from '../../components/DialogManager/recievers'; import {simpleDialogEvent} from '../../components/DialogManager/recievers';
import {TEMPLATE_EXIT_FULLSCREEN} from '../../components/DialogManager/Templates'; import {TEMPLATE_EXIT_FULLSCREEN} from '../../components/DialogManager/Templates';
import { useTracked } from '../../provider'; import {useTracked} from '../../provider';
import {DDS} from '../../services/DeviceDetection'; import {DDS} from '../../services/DeviceDetection';
import { import {
eSendEvent, eSendEvent,
@@ -66,7 +66,10 @@ const EditorRoot = () => {
await loadNote(item); await loadNote(item);
InteractionManager.runAfterInteractions(() => { InteractionManager.runAfterInteractions(() => {
Keyboard.addListener('keyboardDidShow', () => { Keyboard.addListener('keyboardDidShow', () => {
editing.isFocused = true; console.log(editing.currentlyEditing,'current')
if (!editing.movedAway) {
editing.isFocused = true;
}
post('keyboard'); post('keyboard');
}); });
if (!DDS.isTab) { if (!DDS.isTab) {
@@ -128,7 +131,9 @@ const EditorRoot = () => {
} }
await clearEditor(); await clearEditor();
Keyboard.removeListener('keyboardDidShow', () => { Keyboard.removeListener('keyboardDidShow', () => {
editing.isFocused = true; if (!editing.movedAway) {
editing.isFocused = true;
}
post('keyboard'); post('keyboard');
}); });
if (handleBack) { if (handleBack) {