diff --git a/seed/static/seed/js/controllers/inventory_list_controller.js b/seed/static/seed/js/controllers/inventory_list_controller.js index f3e9b3be7c..9119825e55 100644 --- a/seed/static/seed/js/controllers/inventory_list_controller.js +++ b/seed/static/seed/js/controllers/inventory_list_controller.js @@ -1800,8 +1800,8 @@ angular.module('BE.seed.controller.inventory_list', []).controller('inventory_li $scope.restore_status = RESTORE_SETTINGS; let state = inventory_service.loadGridSettings(`${localStorageKey}.sort`); // If save state has filters or sorts, ignore the grids first attempt to run filterChanged or sortChanged - const columns = JSON.parse(state).columns - $scope.ignore_filter_or_sort = !_.isEmpty(columns) + const { columns } = JSON.parse(state) ?? {}; + $scope.ignore_filter_or_sort = !_.isEmpty(columns); if (!_.isNull(state)) { state = JSON.parse(state); $scope.gridApi.saveState.restore($scope, state).then(() => { @@ -1826,14 +1826,13 @@ angular.module('BE.seed.controller.inventory_list', []).controller('inventory_li }; const filterOrSortChanged = _.debounce(() => { - if ($scope.ignore_filter_or_sort) { - $scope.ignore_filter_or_sort = false; - } else if ($scope.restore_status === RESTORE_COMPLETE) { - updateColumnFilterSort(); - $scope.load_inventory(1); - } - }, 1000) - + if ($scope.ignore_filter_or_sort) { + $scope.ignore_filter_or_sort = false; + } else if ($scope.restore_status === RESTORE_COMPLETE) { + updateColumnFilterSort(); + $scope.load_inventory(1); + } + }, 1000); $scope.gridOptions = { data: 'data', @@ -1903,7 +1902,7 @@ angular.module('BE.seed.controller.inventory_list', []).controller('inventory_li saveSettings(); }); gridApi.core.on.columnVisibilityChanged($scope, saveSettings); - gridApi.core.on.filterChanged($scope, filterOrSortChanged) + gridApi.core.on.filterChanged($scope, filterOrSortChanged); gridApi.core.on.sortChanged($scope, filterOrSortChanged); gridApi.pinning.on.columnPinned($scope, (colDef, container) => { if (container) {