fix(ui): preserve scroll position on customer profile feed
This commit is contained in:
+27
-1
@@ -1,4 +1,4 @@
|
|||||||
const state = {
|
const state = {
|
||||||
user: 'admin',
|
user: 'admin',
|
||||||
role: 'admin',
|
role: 'admin',
|
||||||
token: null,
|
token: null,
|
||||||
@@ -1235,7 +1235,18 @@ function renderCustomerSpotlight() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (target && customer) {
|
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);
|
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();
|
renderCustomerProfilePage();
|
||||||
}
|
}
|
||||||
@@ -1277,7 +1288,22 @@ function renderCustomerProfilePage() {
|
|||||||
: `Клиент ${customer.customer_id} • омниканальный профиль`;
|
: `Клиент ${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 });
|
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() {
|
function syncCustomerFormUi() {
|
||||||
|
|||||||
Reference in New Issue
Block a user