fix focus on editor close

This commit is contained in:
ammarahm-ed
2021-01-14 14:36:33 +05:00
parent 5d9b8acd0d
commit 2667fd2261

View File

@@ -6,7 +6,8 @@ import {hexToRGBA} from '../../utils/ColorUtils';
import ActionSheet from 'react-native-actions-sheet';
import {GetPremium} from './GetPremium';
import {editing} from '../../utils';
import { post } from '../../views/Editor/Functions';
import {EditorWebView, post, textInput} from '../../views/Editor/Functions';
import {sleep} from '../../utils/TimeUtils';
const ActionSheetWrapper = ({
children,
@@ -39,9 +40,6 @@ const ActionSheetWrapper = ({
};
}, [colors.bg, gestureEnabled]);
return (
<ActionSheet
ref={fwdRef}
@@ -65,19 +63,31 @@ const ActionSheetWrapper = ({
offset={50}
/>
}
onClose={() => {
console.log(editing.isFocused,editing.focusType)
onClose={async () => {
if (editing.isFocused === true) {
post('blur');
if (editing.focusType == "editor") {
if (editing.focusType == 'editor') {
await sleep(10);
if (Platform.OS === 'android') {
textInput.current?.focus();
post('focusEditor');
EditorWebView.current?.requestFocus();
} else {
post('focusEditor');
}
} else {
await sleep(10);
if (Platform.OS === 'android') {
textInput.current?.focus();
post('focusTitle');
EditorWebView.current?.requestFocus();
} else {
post('focusTitle');
}
}
}
if (onClose) {
onClose()
onClose();
}
}}>
{children}