Skip to content

Commit

Permalink
Merge pull request #958 from compucorp/GIZ-348-fix-for-high-number-re…
Browse files Browse the repository at this point in the history
…quests

GIZ-348: Remove tabsactivate event listener for Contact Summary tabs
  • Loading branch information
olayiwola-compucorp authored Jul 13, 2023
2 parents 84ce6bf + c38540f commit c2d8796
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
5 changes: 3 additions & 2 deletions CRM/Civicase/Hook/PageRun/AddContactPageSummaryResources.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* Class CRM_Civicase_Hook_PageRun_AddContactPageSummaryResources.
* Handles Contact Record Summary Page display.
*/
class CRM_Civicase_Hook_PageRun_AddContactPageSummaryResources {

Expand All @@ -23,7 +23,8 @@ public function run(&$page) {
* Add resources (CSS and JS) for this Page.
*/
private function addResources() {
// Adds Moment.js file.
Civi::resources()
->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');
}
Expand Down
31 changes: 31 additions & 0 deletions js/disable-contact-summary-tab-activate.js
Original file line number Diff line number Diff line change
@@ -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.$);

0 comments on commit c2d8796

Please sign in to comment.