Skip to content

Commit ec276ce

Browse files
authored
Fix run selector toggle all with many items (#2633)
1 parent 96f253c commit ec276ce

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

tensorboard/components/tf_dashboard_common/tf-multi-checkbox.ts

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ namespace tf_dashboard_common {
3737
computed: 'computeNamesMatchingRegex(names.*, _regex)',
3838
}, // Runs that match the regex
3939
selectionState: {
40-
// if a name is explicitly enabled, True, if explicitly disabled, False.
41-
// if undefined, default value (enable for first k names, disable after).
40+
// If a name is explicitly enabled by user gesture, True, if explicitly
41+
// disabled, False. If undefined, default value (enable for first k
42+
// names, disable after).
4243
type: Object,
4344
notify: true,
4445
value: () => ({}),
@@ -168,28 +169,16 @@ namespace tf_dashboard_common {
168169
return this.outSelected.indexOf(item) != -1;
169170
},
170171
toggleAll: function() {
171-
var anyToggledOn = this.namesMatchingRegex.some(
172-
(n) => this.selectionState[n]
173-
);
174-
175-
var selectionStateIsDefault =
176-
Object.keys(this.selectionState).length == 0;
177-
178-
var defaultOff =
179-
this.namesMatchingRegex.length > this.maxRunsToEnableByDefault;
180-
// We have names toggled either if some were explicitly toggled on, or if
181-
// we are in the default state, and there are few enough that we default
182-
// to toggling on.
183-
anyToggledOn = anyToggledOn || (selectionStateIsDefault && !defaultOff);
184-
185172
// If any are toggled on, we turn everything off. Or, if none are toggled
186173
// on, we turn everything on.
187-
188-
var newRunsDisabled = {};
189-
this.names.forEach(function(n) {
190-
newRunsDisabled[n] = !anyToggledOn;
174+
const anyToggledOn = this.namesMatchingRegex.some((name) =>
175+
this.outSelected.includes(name)
176+
);
177+
const newSelectionState = {};
178+
this.names.forEach((n) => {
179+
newSelectionState[n] = !anyToggledOn;
191180
});
192-
this.selectionState = newRunsDisabled;
181+
this.selectionState = newSelectionState;
193182
},
194183
});
195184
} // namespace tf_dashboard_common

0 commit comments

Comments
 (0)