fixed autofocus and expand btn navigation glitch

This commit is contained in:
Sadaqat Ali 2022-05-26 23:40:21 +05:00
parent 5112bd8e1b
commit 6adb32cc9b
3 changed files with 13 additions and 8 deletions
src
components
markdownEditor/view
quickReplyModal
screens/editor/container

View File

@ -181,7 +181,7 @@ const MarkdownEditorView = ({
}, [draftBody]);
useEffect(() => {
if (autoFocusText && inputRef && inputRef.current && draftBtnTooltipRegistered) {
if (isReply || (autoFocusText && inputRef && inputRef.current && draftBtnTooltipRegistered)) {
// added delay to open keyboard, solves the issue of keyboard not opening
setTimeout(() => {
inputRef.current.focus();

View File

@ -7,7 +7,7 @@ import { View, Text, Alert, TouchableOpacity, Keyboard, Platform } from 'react-n
import { useIntl } from 'react-intl';
import { IconButton, MainButton, SummaryArea, TextButton, TextInput, UserAvatar } from '..';
import { useSelector, useDispatch } from 'react-redux';
import { generateReplyPermlink } from '../../utils/editor';
import { delay, generateReplyPermlink } from '../../utils/editor';
import { postComment } from '../../providers/hive/dhive';
import { toastNotification } from '../../redux/actions/uiAction';
import { updateCommentCache } from '../../redux/actions/cacheActions';
@ -48,7 +48,7 @@ const QuickReplyModal = ({ fetchPost }: QuickReplyModalProps, ref) => {
// wait for modal to open and then show the keyboard
setTimeout(() => {
inputRef.current?.focus();
}, 1000);
}, 500);
},
}));
@ -158,8 +158,11 @@ const QuickReplyModal = ({ fetchPost }: QuickReplyModalProps, ref) => {
}
};
const _handleExpandBtn = () => {
const _handleExpandBtn = async () => {
if (selectedPost) {
Keyboard.dismiss();
sheetModalRef.current?.hide();
await delay(50);
navigate({
routeName: ROUTES.SCREENS.EDITOR,
key: 'editor_replay',
@ -170,9 +173,9 @@ const QuickReplyModal = ({ fetchPost }: QuickReplyModalProps, ref) => {
fetchPost,
},
});
sheetModalRef.current?.setModalVisible(false);
}
};
//VIEW_RENDERERS
const _renderSheetHeader = () => (
@ -267,7 +270,7 @@ const QuickReplyModal = ({ fetchPost }: QuickReplyModalProps, ref) => {
<ActionSheet
ref={sheetModalRef}
gestureEnabled={true}
keyboardShouldPersistTaps="handled"
keyboardShouldPersistTaps="always"
containerStyle={styles.sheetContent}
keyboardHandlerEnabled
indicatorColor={EStyleSheet.value('$primaryWhiteLightBackground')}

View File

@ -134,7 +134,8 @@ class EditorContainer extends Component {
({ isReply, quickReplyText } = navigationParams);
this.setState({
isReply,
quickReplyText
quickReplyText,
autoFocusText: true,
});
}
@ -919,7 +920,8 @@ class EditorContainer extends Component {
_handleSubmitSuccess = () => {
const { navigation } = this.props;
console.log('navigation.state.params: ', navigation.state.params);
this.stateTimer = setTimeout(() => {
if (navigation) {
navigation.goBack();