Mobile Search: Fix jumping scroll on mobile
This commit is contained in:
parent
2e135c997b
commit
8ed75455de
@ -12,8 +12,8 @@ import useLang from '../../../hooks/useLang';
|
|||||||
import { renderMessageSummary } from '../../common/helpers/renderMessageText';
|
import { renderMessageSummary } from '../../common/helpers/renderMessageText';
|
||||||
|
|
||||||
import InfiniteScroll from '../../ui/InfiniteScroll';
|
import InfiniteScroll from '../../ui/InfiniteScroll';
|
||||||
import ChatMessage from './ChatMessage';
|
|
||||||
import NothingFound from '../../common/NothingFound';
|
import NothingFound from '../../common/NothingFound';
|
||||||
|
import ChatMessage from './ChatMessage';
|
||||||
import DateSuggest from './DateSuggest';
|
import DateSuggest from './DateSuggest';
|
||||||
|
|
||||||
export type OwnProps = {
|
export type OwnProps = {
|
||||||
|
|||||||
@ -79,13 +79,13 @@ const MobileSearchFooter: FC<StateProps> = ({
|
|||||||
|
|
||||||
// Focus message
|
// Focus message
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (chat && foundIds && foundIds.length) {
|
if (chat?.id && foundIds?.length) {
|
||||||
focusMessage({ chatId: chat.id, messageId: foundIds[foundIds.length - 1] });
|
focusMessage({ chatId: chat.id, messageId: foundIds[0] });
|
||||||
setFocusedIndex(0);
|
setFocusedIndex(0);
|
||||||
} else {
|
} else {
|
||||||
setFocusedIndex(-1);
|
setFocusedIndex(-1);
|
||||||
}
|
}
|
||||||
}, [chat, focusMessage, foundIds]);
|
}, [chat?.id, focusMessage, foundIds]);
|
||||||
|
|
||||||
// Disable native up/down buttons on iOS
|
// Disable native up/down buttons on iOS
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -121,7 +121,7 @@ const MobileSearchFooter: FC<StateProps> = ({
|
|||||||
const handleUp = useCallback(() => {
|
const handleUp = useCallback(() => {
|
||||||
if (chat && foundIds) {
|
if (chat && foundIds) {
|
||||||
const newFocusIndex = focusedIndex + 1;
|
const newFocusIndex = focusedIndex + 1;
|
||||||
focusMessage({ chatId: chat.id, messageId: foundIds[foundIds.length - 1 - newFocusIndex] });
|
focusMessage({ chatId: chat.id, messageId: foundIds[newFocusIndex] });
|
||||||
setFocusedIndex(newFocusIndex);
|
setFocusedIndex(newFocusIndex);
|
||||||
}
|
}
|
||||||
}, [chat, focusedIndex, focusMessage, foundIds]);
|
}, [chat, focusedIndex, focusMessage, foundIds]);
|
||||||
@ -129,7 +129,7 @@ const MobileSearchFooter: FC<StateProps> = ({
|
|||||||
const handleDown = useCallback(() => {
|
const handleDown = useCallback(() => {
|
||||||
if (chat && foundIds) {
|
if (chat && foundIds) {
|
||||||
const newFocusIndex = focusedIndex - 1;
|
const newFocusIndex = focusedIndex - 1;
|
||||||
focusMessage({ chatId: chat.id, messageId: foundIds[foundIds.length - 1 - newFocusIndex] });
|
focusMessage({ chatId: chat.id, messageId: foundIds[newFocusIndex] });
|
||||||
setFocusedIndex(newFocusIndex);
|
setFocusedIndex(newFocusIndex);
|
||||||
}
|
}
|
||||||
}, [chat, focusedIndex, focusMessage, foundIds]);
|
}, [chat, focusedIndex, focusMessage, foundIds]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user