Skip to content

Commit

Permalink
fix: chatitem scrolling out of view closing keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Vali-98 committed Feb 25, 2024
1 parent 644a2dd commit 9338f33
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
8 changes: 7 additions & 1 deletion components/ChatMenu/ChatWindow/ChatItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ const ChatItem: React.FC<ChatItemProps> = ({

{showEditor && (
<View>
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
<View
style={{
flexDirection: 'row',
justifyContent: 'space-between',
marginBottom: 2,
}}>
{id !== 0 && (
<EditorButton name="delete" onPress={handleDeleteMessage} />
)}
Expand All @@ -129,6 +134,7 @@ const ChatItem: React.FC<ChatItemProps> = ({
onChangeText={setPlaceholderText}
textBreakStrategy="simple"
multiline
autoFocus
/>
</View>
</View>
Expand Down
25 changes: 13 additions & 12 deletions components/ChatMenu/ChatWindow/ChatWindow.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { StyleSheet, KeyboardAvoidingView, FlatList } from 'react-native'
import { StyleSheet, FlatList } from 'react-native'
import { ChatItem } from './ChatItem'
import { Chats, Color, Global } from '@globals'
import { Chats, Global } from '@globals'
import { useMMKVBoolean, useMMKVString } from 'react-native-mmkv'
import { useEffect, useRef } from 'react'

Expand Down Expand Up @@ -46,16 +46,17 @@ const ChatWindow = () => {
}

return (
<KeyboardAvoidingView style={styles.chatHistory}>
<FlatList
ref={flatListRef}
inverted
windowSize={3}
data={getItems()}
keyExtractor={(item) => item.key.toString()}
renderItem={renderItems}
/>
</KeyboardAvoidingView>
<FlatList
style={styles.chatHistory}
ref={flatListRef}
keyboardShouldPersistTaps={'handled'}
removeClippedSubviews={false}
inverted
windowSize={3}
data={getItems()}
keyExtractor={(item) => item.key.toString()}
renderItem={renderItems}
/>
)
}

Expand Down

0 comments on commit 9338f33

Please sign in to comment.