added blur for chat

This commit is contained in:
SlimusMinus
2026-10-14 02:06:20 +03:00
parent 4c27de1ca5
commit 289695a244
2 changed files with 104 additions and 4 deletions

View File

@@ -30,6 +30,7 @@ export default function ChatPage() {
const [loadError, setLoadError] = useState("");
const [sendError, setSendError] = useState("");
const messagesEndRef = useRef(null);
const pageRef = useRef(null);
const myUserId = user?.id;
@@ -80,6 +81,25 @@ export default function ChatPage() {
return () => setActiveChatId(null);
}, [chatId, fetchMessages, markAsRead, clearChatUnread, t]);
// Шапка и поле ввода лежат поверх ленты сообщений — меряем их высоту в
// CSS-переменные --chat-header-height / --chat-input-height, чтобы первое
// и последнее сообщения не прятались под ними.
useEffect(() => {
const page = pageRef.current;
const header = page?.querySelector(".chat-header");
const inputArea = page?.querySelector(".chat-input-area");
if (!header || !inputArea) return;
const update = () => {
page.style.setProperty("--chat-header-height", `${header.offsetHeight}px`);
page.style.setProperty("--chat-input-height", `${inputArea.offsetHeight}px`);
};
update();
const ro = new ResizeObserver(update);
ro.observe(header);
ro.observe(inputArea);
return () => ro.disconnect();
}, []);
useEffect(() => {
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
}, [messages]);
@@ -115,7 +135,7 @@ export default function ChatPage() {
return (
<div className="f-app">
<div className="chat-page">
<div className="chat-page chat-page--open" ref={pageRef}>
<ChatHeader
title={post?.title || t('chat.title')}
onBack={() => navigate("/chats")}