SearchKit - Fix wrong column being removed from displays
authorcolemanw <coleman@civicrm.org>
Fri, 29 Dec 2023 20:24:32 +0000 (14:24 -0600)
committercolemanw <coleman@civicrm.org>
Fri, 29 Dec 2023 20:24:32 +0000 (14:24 -0600)
Fixes recent regression from 4099cd6 causing the wrong column to be removed from a display.
To reproduce: Create a search display, go back to the main search criteria and delete a column,
then tab back to the display. The deleted column should have been removed but instead the wrong
one is still there.

ext/search_kit/ang/crmSearchAdmin/crmSearchAdminDisplay.component.js

index 7d1b856fb2d86bda8ea9755dd0e756cda6d4a28f..2e92948a525f19c678e270f611e43bf3834214fb 100644 (file)
           let selectAliases = ctrl.savedSearch.api_params.select.map(selectExpr => selectToKey(selectExpr));
           // Delete any column that is no longer in the
           activeColumns.reverse().forEach((key, index) => {
-            if (key && !_.includes(selectAliases, key)) {
-              ctrl.display.settings.columns.splice(index, 1);
+            if (key && !selectAliases.includes(key)) {
+              ctrl.removeCol(activeColumns.length - 1 - index);
             }
           });
         }