Skip to content

Commit 58981c1

Browse files
committed
Fix UI scrolling issue on dashboard refresh
Preserve scroll position when updating dashboard content to prevent unwanted page jumping during live updates. This improves user experience, particularly when viewing the recent queries section at the bottom of the page.
1 parent 19d444d commit 58981c1

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

dnscrypt-proxy/monitoring_ui_templates.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,12 @@ function safeUpdateDashboard(data) {
318318
319319
console.log('Updating dashboard with data');
320320
321+
// Store the current scroll position before updates
322+
const scrollPos = {
323+
x: window.scrollX || window.pageXOffset,
324+
y: window.scrollY || window.pageYOffset
325+
};
326+
321327
// Hide loading indicator when data is loaded
322328
var loadingIndicator = document.getElementById('loading-indicator');
323329
if (loadingIndicator) {
@@ -393,6 +399,9 @@ function safeUpdateDashboard(data) {
393399
row.insertCell(6).textContent = (query.response_time || 0) + ' ms';
394400
});
395401
}
402+
403+
// Restore scroll position after DOM updates
404+
window.scrollTo(scrollPos.x, scrollPos.y);
396405
} catch (error) {
397406
console.error('Error updating dashboard:', error);
398407
}

0 commit comments

Comments
 (0)