Skip to content

Commit 63f0c9f

Browse files
authored
Merge pull request #54968 from christianwen/fix/54629-2
fix composer show up when back to foreground
2 parents b04982c + bfcac68 commit 63f0c9f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx

+16-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type {
1111
TextInputKeyPressEventData,
1212
TextInputScrollEventData,
1313
} from 'react-native';
14-
import {DeviceEventEmitter, findNodeHandle, InteractionManager, NativeModules, View} from 'react-native';
14+
import {AppState, DeviceEventEmitter, findNodeHandle, InteractionManager, Keyboard, NativeModules, View} from 'react-native';
1515
import {useFocusedInputHandler} from 'react-native-keyboard-controller';
1616
import type {OnyxEntry} from 'react-native-onyx';
1717
import {useOnyx} from 'react-native-onyx';
@@ -735,6 +735,21 @@ function ComposerWithSuggestions(
735735
tag.set(findNodeHandle(textInputRef.current) ?? -1);
736736
}, [tag]);
737737

738+
useEffect(() => {
739+
const appStateSubscription = AppState.addEventListener('change', (nextAppState) => {
740+
if (!nextAppState.match(/inactive|background/)) {
741+
focus(true);
742+
return;
743+
}
744+
745+
Keyboard.dismiss();
746+
});
747+
748+
return () => {
749+
appStateSubscription.remove();
750+
};
751+
}, [focus]);
752+
738753
useFocusedInputHandler(
739754
{
740755
onSelectionChange: (event) => {

0 commit comments

Comments
 (0)