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

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