Skip to content

Commit 9366e65

Browse files
committed
fix: keyboard
1 parent 599957e commit 9366e65

File tree

1 file changed

+15
-2
lines changed
  • app/views/RoomView/List/components

1 file changed

+15
-2
lines changed

app/views/RoomView/List/components/List.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, { useMemo, useState } from 'react';
2-
import { type NativeScrollEvent, type NativeSyntheticEvent, StyleSheet, View } from 'react-native';
1+
import React, { useEffect, useMemo, useState } from 'react';
2+
import { type NativeScrollEvent, type NativeSyntheticEvent, StyleSheet, View, Keyboard } from 'react-native';
33
import { FlashList } from '@shopify/flash-list';
44

55
import { type IListProps } from '../definitions';
@@ -40,6 +40,19 @@ const List = ({ listRef, jumpToBottom, ...props }: IListProps) => {
4040
}
4141
};
4242

43+
// Scroll to end when keyboard opens
44+
useEffect(() => {
45+
const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () => {
46+
if (listRef?.current) {
47+
listRef.current.scrollToEnd({ animated: true });
48+
}
49+
});
50+
51+
return () => {
52+
keyboardDidShowListener.remove();
53+
};
54+
}, [listRef]);
55+
4356
return (
4457
<View style={styles.list}>
4558
<FlashList

0 commit comments

Comments
 (0)