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

View File

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

View File

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