From 39c5d0d4543dffe1e2bb3fe0f448749a0e8d1e87 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Tue, 5 Jul 2022 16:29:43 +0530 Subject: [PATCH] fix: only update URL if active list is still same If you rapidly move from a list view while it was being refreshed then changed URL is applied on a page that MIGHT not be the list/report view. This check ensures that same page is present before updating URL. --- frappe/public/js/frappe/list/list_view.js | 5 ++++- frappe/public/js/frappe/views/reports/query_report.js | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/frappe/public/js/frappe/list/list_view.js b/frappe/public/js/frappe/list/list_view.js index 3a39a949c9..5378cdb251 100644 --- a/frappe/public/js/frappe/list/list_view.js +++ b/frappe/public/js/frappe/list/list_view.js @@ -1456,7 +1456,10 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { on_update() {} update_url_with_filters() { - window.history.replaceState(null, null, this.get_url_with_filters()); + if (frappe.get_route_str() == this.page_name) { + // only update URL if the route still matches current page. + window.history.replaceState(null, null, this.get_url_with_filters()); + } } get_url_with_filters() { diff --git a/frappe/public/js/frappe/views/reports/query_report.js b/frappe/public/js/frappe/views/reports/query_report.js index ac7f8327ab..80b251e5ec 100644 --- a/frappe/public/js/frappe/views/reports/query_report.js +++ b/frappe/public/js/frappe/views/reports/query_report.js @@ -58,7 +58,9 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList { } update_url_with_filters() { - window.history.replaceState(null, null, this.get_url_with_filters()); + if (frappe.get_route_str() == this.page_name) { + window.history.replaceState(null, null, this.get_url_with_filters()); + } } get_url_with_filters() {