SearchKit - Fix console errors when adding non-field columns
authorColeman Watts <coleman@civicrm.org>
Wed, 20 Oct 2021 18:50:51 +0000 (14:50 -0400)
committerColeman Watts <coleman@civicrm.org>
Thu, 21 Oct 2021 02:54:54 +0000 (22:54 -0400)
ext/search_kit/ang/crmSearchAdmin/crmSearchAdminDisplay.component.js

index 9bb5c4f7f7400a01613fa7084b7582f11335cdc7..22219d66720db11cbdc25e25d1af2b053ded533d 100644 (file)
         return !col.image && !col.rewrite && !col.link && !info.fn && info.args[0] && info.args[0].field && !info.args[0].field.readonly;
       };
 
+      // Checks if a column contains a sortable value
+      // Must be a real sql expression (not a pseudo-field like `result_row_num`)
       this.canBeSortable = function(col) {
         var expr = ctrl.getExprFromSelect(col.key),
           info = searchMeta.parseExpr(expr),
-          arg = (_.findWhere(info.args, {type: 'field'}) || {});
+          arg = (info && info.args && _.findWhere(info.args, {type: 'field'})) || {};
         return arg.field && arg.field.type !== 'Pseudo';
       };