From 041e905a44bd96bd4e9e8734c8af83010fc22440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C=20=D0=9D=D0=B0=D0=B4=D0=B5?= =?UTF-8?q?=D0=B8=D0=BD?= Date: Tue, 13 Jan 2026 09:30:18 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=B7=D0=B0=D0=BC=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=BB=20scrollTo()=20=D0=BD=D0=B0=20=D0=BF=D1=80=D1=8F=D0=BC?= =?UTF-8?q?=D0=BE=D0=B5=20=D0=BF=D1=80=D0=B8=D1=81=D0=B2=D0=BE=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20scrollTop=20=D0=BF=D1=80=D0=B8=20=D0=B8=D0=BD?= =?UTF-8?q?=D0=B8=D1=86=D0=B8=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - scrollTo() НЕ работает при первичной загрузке (scrollTop остается 0) - используется прямое присвоение scrollTop как в legacy коде - тройной RAF для надежности - это должно исправить проблему с автозагрузкой истории --- .../static/js/controllers/chatControllerV2.js | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/backend/static/js/controllers/chatControllerV2.js b/backend/static/js/controllers/chatControllerV2.js index 73ffdd10..42d98d57 100644 --- a/backend/static/js/controllers/chatControllerV2.js +++ b/backend/static/js/controllers/chatControllerV2.js @@ -143,28 +143,25 @@ export class ChatControllerV2 { clientHeight: this.scrollElement.clientHeight }); - // Используем scrollTo() вместо scrollTop (более надежно) + // Используем ПРЯМОЕ присвоение scrollTop (как в legacy коде) + // scrollTo() НЕ работает на первичной загрузке await new Promise(resolve => { requestAnimationFrame(() => { requestAnimationFrame(() => { - const targetScroll = this.scrollElement.scrollHeight; - - // Используем scrollTo с auto (не smooth!) - this.scrollElement.scrollTo({ - top: targetScroll, - behavior: 'auto' + requestAnimationFrame(() => { + // Тройной RAF для надежности + this.scrollElement.scrollTop = this.scrollElement.scrollHeight; + + // Проверяем через setTimeout + setTimeout(() => { + console.log('[ChatControllerV2] After scrollTop:', { + scrollHeight: this.scrollElement.scrollHeight, + scrollTop: this.scrollElement.scrollTop, + success: this.scrollElement.scrollTop > 0 + }); + resolve(); + }, 10); }); - - // Проверяем через setTimeout - setTimeout(() => { - console.log('[ChatControllerV2] After scrollTo:', { - scrollHeight: this.scrollElement.scrollHeight, - scrollTop: this.scrollElement.scrollTop, - targetScroll, - success: Math.abs(this.scrollElement.scrollTop - targetScroll) < 5 - }); - resolve(); - }, 10); }); }); });