mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
fix focus on editor close
This commit is contained in:
@@ -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>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user