Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions app/containers/MessageComposer/components/ComposerInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import { usePrevious } from '../../../lib/hooks/usePrevious';
import { ChatsStackParamList } from '../../../stacks/types';
import { loadDraftMessage } from '../../../lib/methods/draftMessage';
import useIOSBackSwipeHandler from '../hooks/useIOSBackSwipeHandler';

const defaultSelection: IInputSelection = { start: 0, end: 0 };

Expand Down Expand Up @@ -65,6 +66,9 @@
useMicOrSend();
const { saveMessageDraft } = useAutoSaveDraft(textRef.current);

// workaround to handle issues with iOS back swipe navigation
const { iOSBackSwipe } = useIOSBackSwipeHandler();

// Draft/Canned Responses
useEffect(() => {
const setDraftMessage = async () => {
Expand All @@ -85,7 +89,7 @@
}
if (sharing) return;
if (usedCannedResponse) setInput(usedCannedResponse);
}, [action, rid, tmid, usedCannedResponse]);

Check warning on line 92 in app/containers/MessageComposer/components/ComposerInput.tsx

View workflow job for this annotation

GitHub Actions / ESLint and Test / run-eslint-and-test

React Hook useEffect has missing dependencies: 'setInput', 'setQuotesAndText', and 'sharing'. Either include them or remove the dependency array

// Edit/quote
useEffect(() => {
Expand Down Expand Up @@ -204,8 +208,10 @@
};

const onBlur: TextInputProps['onBlur'] = () => {
setFocused(false);
stopAutocomplete();
if (!iOSBackSwipe.current) {
setFocused(false);
stopAutocomplete();
}
};

const onAutocompleteItemSelected: IAutocompleteItemProps['onPress'] = async item => {
Expand Down
36 changes: 36 additions & 0 deletions app/containers/MessageComposer/hooks/useIOSBackSwipeHandler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { useEffect, useRef } from 'react';
import { Keyboard } from 'react-native';
import { useNavigation } from '@react-navigation/native';

import { isIOS } from '../../../lib/methods/helpers';

const useIOSBackSwipeHandler = () => {
const navigation = useNavigation();
const iOSBackSwipe = useRef<boolean>(false);

useEffect(() => {
if (!isIOS) return;

const transitionStartListener = navigation.addListener('transitionStart' as any, e => {
if (e?.data?.closing) {
iOSBackSwipe.current = true;
Keyboard.dismiss();
}
});

const transitionEndListener = navigation.addListener('transitionEnd' as any, e => {
if (e?.data?.closing) {
iOSBackSwipe.current = false;
}
});

return () => {
transitionStartListener();
transitionEndListener();
};
}, []);

return { iOSBackSwipe };
};

export default useIOSBackSwipeHandler;
Loading