From da2cd31c32d5149b7fa2a1221e622bf7006fd896 Mon Sep 17 00:00:00 2001 From: Yera All Date: Tue, 7 Apr 2026 00:04:47 +0500 Subject: [PATCH] fix(ui): preserve scroll position on customer profile feed --- ui/operator/app.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/ui/operator/app.js b/ui/operator/app.js index 1cbbe73..985bff7 100644 --- a/ui/operator/app.js +++ b/ui/operator/app.js @@ -1,4 +1,4 @@ -const state = { +const state = { user: 'admin', role: 'admin', token: null, @@ -1235,7 +1235,18 @@ function renderCustomerSpotlight() { ); } if (target && customer) { + const listEl = target.querySelector('.customer-history-list'); + const scrollPos = listEl ? listEl.scrollTop : 0; + const h = target.offsetHeight; + if (h > 0) target.style.minHeight = h + 'px'; + target.innerHTML = customerSpotlightMarkup(customer); + + if (h > 0) target.style.minHeight = ''; + const newListEl = target.querySelector('.customer-history-list'); + if (newListEl && scrollPos > 0) { + newListEl.scrollTop = scrollPos; + } } renderCustomerProfilePage(); } @@ -1277,7 +1288,22 @@ function renderCustomerProfilePage() { : `Клиент ${customer.customer_id} • омниканальный профиль`; } + const listEl = target.querySelector('.customer-history-list'); + const scrollPos = listEl ? listEl.scrollTop : 0; + const pageScroll = window.scrollY || document.documentElement.scrollTop; + const h = target.offsetHeight; + if (h > 0) target.style.minHeight = h + 'px'; + target.innerHTML = customerSpotlightMarkup(customer, { pageView: true }); + + if (h > 0) target.style.minHeight = ''; + const newListEl = target.querySelector('.customer-history-list'); + if (newListEl && scrollPos > 0) { + newListEl.scrollTop = scrollPos; + } + if (pageScroll > 0 && pageScroll > window.scrollY) { + window.scrollTo(window.scrollX, pageScroll); + } } function syncCustomerFormUi() {