SearchKit - Fix clearing selection behavior
authorColeman Watts <coleman@civicrm.org>
Sat, 27 Feb 2021 01:50:57 +0000 (20:50 -0500)
committerColeman Watts <coleman@civicrm.org>
Sat, 27 Feb 2021 01:50:57 +0000 (20:50 -0500)
The variables `allRowsSelected` and `selectedRows` were sometimes getting out-of-sync.
This adds a function to help ensure they both get updated at the same time when the selection needs to be cleared.

ext/search/ang/crmSearchAdmin/crmSearchAdmin.component.js

index a72084d26dca0caeb91b259e9d975c7125038eaa..a74fdf9acaaad17252a1f467fdb5e48f7538d934 100644 (file)
 
       this.refreshAll = function() {
         ctrl.stale = true;
-        ctrl.selectedRows.length = 0;
+        clearSelection();
         loadResults();
       };
 
 
       function onChangeFilters() {
         ctrl.stale = true;
-        ctrl.selectedRows.length = 0;
+        clearSelection();
         if (ctrl.autoSearch) {
           ctrl.refreshAll();
         }
       }
 
+      function clearSelection() {
+        ctrl.allRowsSelected = false;
+        ctrl.selectedRows.length = 0;
+      }
+
       $scope.selectAllRows = function() {
         // Deselect all
         if (ctrl.allRowsSelected) {
-          ctrl.allRowsSelected = false;
-          ctrl.selectedRows.length = 0;
+          clearSelection();
           return;
         }
         // Select all