Skip to content

Commit 12b428d

Browse files
Use angular.copy to keep a current copy of the config
1 parent 37275fd commit 12b428d

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

src/filters/filter-fields-component.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,21 @@ angular.module('patternfly.filters').component('pfFilterFields', {
7272
}
7373

7474
function setupConfig () {
75-
prevConfig = ctrl.config;
75+
var fieldFound = false;
76+
77+
prevConfig = angular.copy(ctrl.config);
7678

7779
if (ctrl.config.fields === undefined) {
7880
ctrl.config.fields = [];
7981
}
80-
if (!ctrl.currentField || ctrl.config.fields.indexOf((ctrl.currentField) === -1)) {
82+
83+
if (ctrl.currentField) {
84+
fieldFound = _.find(ctrl.config.fields, function (nextField) {
85+
return nextField.id === ctrl.currentField.id;
86+
});
87+
}
88+
89+
if (!fieldFound) {
8190
ctrl.currentField = ctrl.config.fields[0];
8291
ctrl.currentValue = null;
8392
}

src/filters/filter-results-component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ angular.module('patternfly.filters').component('pfFilterResults', {
5353
};
5454

5555
function setupConfig () {
56-
prevConfig = ctrl.config;
56+
prevConfig = angular.copy(ctrl.config);
5757

5858
if (!ctrl.config.appliedFilters) {
5959
ctrl.config.appliedFilters = [];

src/sort/sort-component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ angular.module('patternfly.sort').component('pfSort', {
3131
function setupConfig () {
3232
var updated = false;
3333

34-
prevConfig = ctrl.config;
34+
prevConfig = angular.copy(ctrl.config);
3535

3636
if (ctrl.config.fields === undefined) {
3737
ctrl.config.fields = [];

src/toolbars/toolbar-component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ angular.module('patternfly.toolbars').component('pfToolbar', {
3434
};
3535

3636
function setupConfig () {
37-
prevConfig = ctrl.config;
37+
prevConfig = angular.copy(ctrl.config);
3838

3939
if (ctrl.config && ctrl.config.viewsConfig && ctrl.config.viewsConfig.views) {
4040
ctrl.config.viewsConfig.viewsList = angular.copy(ctrl.config.viewsConfig.views);

0 commit comments

Comments
 (0)