fix editor focus after closing actionsheet

This commit is contained in:
ammarahm-ed
2021-02-04 14:35:32 +05:00
parent a1c4cb9805
commit 57f6c7a390
2 changed files with 16 additions and 20 deletions

View File

@@ -6,8 +6,15 @@ import {hexToRGBA} from '../../utils/ColorUtils';
import ActionSheet from 'react-native-actions-sheet';
import {GetPremium} from './GetPremium';
import {editing} from '../../utils';
import {EditorWebView, post, textInput} from '../../views/Editor/Functions';
import {
editorTitleInput,
EditorWebView,
post,
textInput,
} from '../../views/Editor/Functions';
import {sleep} from '../../utils/TimeUtils';
import tiny from '../../views/Editor/tiny/tiny';
import {focusEditor} from '../../views/Editor/tiny/toolbar/constants';
const ActionSheetWrapper = ({
children,
@@ -65,27 +72,15 @@ const ActionSheetWrapper = ({
}
onClose={async () => {
if (editing.isFocused === true) {
textInput.current?.focus();
await sleep(10);
if (editing.focusType == 'editor') {
await sleep(10);
if (Platform.OS === 'android') {
textInput.current?.focus();
post('focusEditor');
EditorWebView.current?.requestFocus();
focusEditor();
} else {
post('focusEditor');
}
} else {
await sleep(10);
if (Platform.OS === 'android') {
textInput.current?.focus();
post('focusTitle');
EditorWebView.current?.requestFocus();
} else {
post('focusTitle');
Platform.OS === 'android' && EditorWebView.current.requestFocus();
tiny.call(EditorWebView, tiny.focusTitle);
}
}
}
if (onClose) {
onClose();
}

View File

@@ -17,7 +17,8 @@ import {
} from '../../utils/Events';
import {SIZE} from '../../utils/SizeUtils';
import {sleep} from '../../utils/TimeUtils';
import {post} from '../../views/Editor/Functions';
import {EditorWebView, post} from '../../views/Editor/Functions';
import tiny from '../../views/Editor/tiny/tiny';
import {Button} from '../Button';
import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph';
@@ -99,7 +100,7 @@ export const GetPremium = ({close, context = 'global', offset = 0}) => {
open(null);
eSendEvent(eCloseActionSheet);
if (editing.isFocused) {
post('blur');
tiny.call(EditorWebView,tiny.blur)
}
await sleep(300);
eSendEvent(eOpenPremiumDialog);