SHA256
Чат и обсуждения: шапка не уезжает за экран при открытой клавиатуре
В поиске по переписке после ввода текста шапка с «раньше/позже» уезжала за верхний край экрана, и переключать совпадения было нечем. Причина – scrollIntoView: он прокручивает не только ленту, но и все внешние контейнеры и видимую область браузера, а при открытой клавиатуре видимая область меньше экрана приложения. Теперь прокручивается только сама лента (общий scrollNodeIntoContainer в services/scroll-utils.js): поиск и «перейти к дате», переход к цитате, «к последнему», разделитель «Новые сообщения», а также переходы к ответу и к записи в обсуждениях и ленте канала.
This commit is contained in:
@@ -53,6 +53,7 @@ import {
|
||||
import { DM_CHAT_PREFS_EVENT, isDmChatMuted, isDmChatPinned, setDmChatPinned } from '../services/dm-chat-prefs.js';
|
||||
import { createDmMuteMenuItem } from '../components/dm-mute-menu.js';
|
||||
import { actionErrorText, mediaAccessErrorText } from '../services/ui-error-texts.js';
|
||||
import { scrollNodeIntoContainer } from '../services/scroll-utils.js';
|
||||
import { loadProfileSnapshot } from '../services/user-profile-params.js';
|
||||
import { makeProfileLinksRoute, makeProfileRoute } from '../services/shine-routes.js';
|
||||
import { openHistoryLayer } from '../router.js';
|
||||
@@ -932,9 +933,7 @@ function scrollToLatestMessage(list) {
|
||||
const scrollContainer = findChatScrollContainer(list);
|
||||
const lastBubble = list.lastElementChild;
|
||||
const apply = () => {
|
||||
if (lastBubble?.scrollIntoView) {
|
||||
lastBubble.scrollIntoView({ block: 'end', inline: 'nearest' });
|
||||
}
|
||||
scrollNodeIntoContainer(lastBubble, { container: scrollContainer, block: 'end' });
|
||||
scrollContainer.scrollTop = scrollContainer.scrollHeight;
|
||||
};
|
||||
apply();
|
||||
@@ -1092,15 +1091,11 @@ function createDmVoiceAttachmentCard(attachment) {
|
||||
function scrollToLatestMessageSmart(list, { smoothIfNearBottom = false } = {}) {
|
||||
if (!list) return;
|
||||
const scrollContainer = findChatScrollContainer(list);
|
||||
const lastBubble = list.lastElementChild;
|
||||
const maxScrollTop = Math.max(0, scrollContainer.scrollHeight - scrollContainer.clientHeight);
|
||||
const distanceToBottom = Math.max(0, maxScrollTop - scrollContainer.scrollTop);
|
||||
const useSmooth = smoothIfNearBottom && distanceToBottom <= 180;
|
||||
|
||||
const apply = (behavior = useSmooth ? 'smooth' : 'auto') => {
|
||||
if (lastBubble?.scrollIntoView) {
|
||||
lastBubble.scrollIntoView({ block: 'end', inline: 'nearest', behavior });
|
||||
}
|
||||
if (behavior === 'smooth' && typeof scrollContainer.scrollTo === 'function') {
|
||||
scrollContainer.scrollTo({ top: scrollContainer.scrollHeight, behavior: 'smooth' });
|
||||
} else {
|
||||
@@ -1119,9 +1114,7 @@ function scrollToUnreadSeparator(list) {
|
||||
if (!separator) return false;
|
||||
const scrollContainer = findChatScrollContainer(list);
|
||||
const apply = () => {
|
||||
if (separator?.scrollIntoView) {
|
||||
separator.scrollIntoView({ block: 'start', inline: 'nearest' });
|
||||
}
|
||||
scrollNodeIntoContainer(separator, { container: scrollContainer, block: 'start' });
|
||||
const bottomSlack = 72;
|
||||
scrollContainer.scrollTop = Math.max(0, scrollContainer.scrollTop - bottomSlack);
|
||||
};
|
||||
@@ -1273,9 +1266,7 @@ function renderLog(
|
||||
replyBox.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
const targetNode = list.querySelector(`[data-base-key="${CSS.escape(String(replyTarget?.baseKey || ''))}"]`);
|
||||
if (targetNode?.scrollIntoView) {
|
||||
targetNode.scrollIntoView({ block: 'center', inline: 'nearest', behavior: 'smooth' });
|
||||
}
|
||||
scrollNodeIntoContainer(targetNode, { container: findChatScrollContainer(list), block: 'center', behavior: 'smooth' });
|
||||
});
|
||||
bubble.append(replyBox);
|
||||
}
|
||||
@@ -1691,7 +1682,7 @@ export function render({ navigate, route, chrome }) {
|
||||
if (!node) return;
|
||||
stickToBottom = false;
|
||||
const distance = Math.abs(node.getBoundingClientRect().top - wrap.getBoundingClientRect().top - wrap.clientHeight / 2);
|
||||
node.scrollIntoView({ block, behavior: distance < wrap.clientHeight ? 'smooth' : 'auto' });
|
||||
scrollNodeIntoContainer(node, { container: wrap, block, behavior: distance < wrap.clientHeight ? 'smooth' : 'auto' });
|
||||
};
|
||||
|
||||
const findBubble = (messageKey) => (messageKey
|
||||
|
||||
Reference in New Issue
Block a user