hide keyboard when backgrounding (#8450)

This commit is contained in:
Samuel Newman
2025-06-11 23:19:26 +03:00
committed by GitHub
parent 9e186dd2b5
commit 093454f5b2
+15
View File
@@ -64,6 +64,7 @@ import {
type SupportedMimeTypes, type SupportedMimeTypes,
} from '#/lib/constants' } from '#/lib/constants'
import {useAnimatedScrollHandler} from '#/lib/hooks/useAnimatedScrollHandler_FIXED' import {useAnimatedScrollHandler} from '#/lib/hooks/useAnimatedScrollHandler_FIXED'
import {useAppState} from '#/lib/hooks/useAppState'
import {useIsKeyboardVisible} from '#/lib/hooks/useIsKeyboardVisible' import {useIsKeyboardVisible} from '#/lib/hooks/useIsKeyboardVisible'
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback' import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
import {usePalette} from '#/lib/hooks/usePalette' import {usePalette} from '#/lib/hooks/usePalette'
@@ -822,6 +823,8 @@ let ComposerPost = React.memo(function ComposerPost({
[post.id, onSelectVideo, onImageAdd, _], [post.id, onSelectVideo, onImageAdd, _],
) )
useHideKeyboardOnBackground()
return ( return (
<View <View
style={[ style={[
@@ -1522,6 +1525,18 @@ function isEmptyPost(post: PostDraft) {
) )
} }
function useHideKeyboardOnBackground() {
const appState = useAppState()
useEffect(() => {
if (isIOS) {
if (appState === 'inactive') {
Keyboard.dismiss()
}
}
}, [appState])
}
const styles = StyleSheet.create({ const styles = StyleSheet.create({
topbarInner: { topbarInner: {
flexDirection: 'row', flexDirection: 'row',