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

View File

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