Auto-scroll chat timeline to bottom when Android keyboard opens.
This commit is contained in:
parent
84eeac93d8
commit
14ed080bc1
2 changed files with 21 additions and 1 deletions
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, viewport-fit=cover" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, viewport-fit=cover, interactive-widget=resizes-content" />
|
||||
<title>Vojo</title>
|
||||
<meta name="name" content="Vojo" />
|
||||
<meta name="author" content="Vojo" />
|
||||
|
|
|
|||
|
|
@ -707,6 +707,26 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
|||
useCallback(() => roomInputRef.current, [roomInputRef])
|
||||
);
|
||||
|
||||
// Stay at bottom when scroll container resizes (e.g. Android keyboard open/close)
|
||||
useResizeObserver(
|
||||
useMemo(() => {
|
||||
let mounted = false;
|
||||
return (_entries: ResizeObserverEntry[]) => {
|
||||
if (!mounted) {
|
||||
mounted = true;
|
||||
return;
|
||||
}
|
||||
if (atBottomRef.current) {
|
||||
requestAnimationFrame(() => {
|
||||
const el = getScrollElement();
|
||||
if (el) scrollToBottom(el);
|
||||
});
|
||||
}
|
||||
};
|
||||
}, [getScrollElement]),
|
||||
getScrollElement
|
||||
);
|
||||
|
||||
const tryAutoMarkAsRead = useCallback(() => {
|
||||
const readUptoEventId = readUptoEventIdRef.current;
|
||||
if (!readUptoEventId) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue