From c38540fa4662984d54aa855ac01cc654bd62f5f1 Mon Sep 17 00:00:00 2001 From: Debarshi Bhaumik Date: Thu, 13 Jul 2023 13:33:43 +0530 Subject: [PATCH] GIZ-348: Remove tabsactivate event listener for Contact Summary tabs --- .../AddContactPageSummaryResources.php | 5 +-- js/disable-contact-summary-tab-activate.js | 31 +++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 js/disable-contact-summary-tab-activate.js diff --git a/CRM/Civicase/Hook/PageRun/AddContactPageSummaryResources.php b/CRM/Civicase/Hook/PageRun/AddContactPageSummaryResources.php index b28f62a67..9d6020908 100644 --- a/CRM/Civicase/Hook/PageRun/AddContactPageSummaryResources.php +++ b/CRM/Civicase/Hook/PageRun/AddContactPageSummaryResources.php @@ -1,7 +1,7 @@ addScriptFile('uk.co.compucorp.civicase', 'js/disable-contact-summary-tab-activate.js', 2, 'html-header'); CRM_Core_Resources::singleton() ->addScriptFile('uk.co.compucorp.civicase', 'packages/moment.min.js'); } diff --git a/js/disable-contact-summary-tab-activate.js b/js/disable-contact-summary-tab-activate.js new file mode 100644 index 000000000..be5aa60e6 --- /dev/null +++ b/js/disable-contact-summary-tab-activate.js @@ -0,0 +1,31 @@ +(function ($) { + /** + * The following line of code is to fix GIZ-348. + * + * In Contact Summary tab, we faced an issue where if we click 2 angular based + * tabs(For example: Activity, Case, Awards tabs) very quickly. Then thousands + * of network requests are being sent to the backend, which is freezing the + * webpage and sometimes crashing the server. + * + * This issue was found after upgrading to CiviCRM 5.51 from 5.39. + * + * Later we identified the issue in CiviCRM core, specifically in + * https://github.com/civicrm/civicrm-core/commit/1ed9f5c505fc61802542e8dc05415fe4a1d99198. + * + * In the above commit in CiviCRM core, code was introduced to add `selectedChild` + * query parameter whenever we click on a Contact Summary page tab. And because + * of this, as the route was changed, AngularJS router was getting confused. + * + * So we are adding this fix, where we remove the `tabsactivate` listener from + * `#mainTabContainer` so that `selectedChild` is not added to the URL. + * + * Note: This is not a perfect solution, but it will work fine for now. + * In the long run, we should try to contact with CiviCRM core, and get it fixed + * there. This issue should be reproducible(need to confirm) in a vanilla + * CiviCRM Core site, with https://github.com/civicrm/org.civicrm.civicase installed. + * That way it will be easier to convince Core team to fix this. + */ + $(function ($) { + $('#mainTabContainer').off('tabsactivate'); + }); +})(CRM.$);