From 3b80106901dbcb63fb0d4a8f0943d4a3e8ef5555 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 26 Feb 2021 20:50:57 -0500 Subject: [PATCH] SearchKit - Fix clearing selection behavior 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. --- .../ang/crmSearchAdmin/crmSearchAdmin.component.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ext/search/ang/crmSearchAdmin/crmSearchAdmin.component.js b/ext/search/ang/crmSearchAdmin/crmSearchAdmin.component.js index a72084d26dca..a74fdf9acaaa 100644 --- a/ext/search/ang/crmSearchAdmin/crmSearchAdmin.component.js +++ b/ext/search/ang/crmSearchAdmin/crmSearchAdmin.component.js @@ -520,7 +520,7 @@ this.refreshAll = function() { ctrl.stale = true; - ctrl.selectedRows.length = 0; + clearSelection(); loadResults(); }; @@ -577,17 +577,21 @@ 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