Skip to content

Commit bb74d91

Browse files
committed
compoundFilter: one tag is a string, not an array - convert to array
fixes being unable to add more tags to filter when filtering by 1 tag (it works when 0 tags, falling back to []; works when 2+ tags because it is automatically an array; but fails to add/remove tags when only one is selected)
1 parent 01dd284 commit bb74d91

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/components/patternfly-wrappers/compound-filter.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,17 @@ export class CompoundFilter extends React.Component<IProps, IState> {
242242

243243
private onSelectMultiple = (event) => {
244244
let newParams = this.props.params[this.state.selectedFilter.id];
245+
246+
// no tags => falsy
247+
// 1 tag => "foo"
248+
// 2+ tags => ["foo", "bar"]
249+
// convert all to an array
245250
if (!newParams) {
246251
newParams = [];
247252
}
253+
if (!Array.isArray(newParams)) {
254+
newParams = [newParams];
255+
}
248256

249257
// TODO: Remove this replace after patternfly fixes the pf-random-id issue
250258
const selectedID = event.currentTarget.id.replace(/pf-random-id-\d+-/, '');
@@ -256,6 +264,7 @@ export class CompoundFilter extends React.Component<IProps, IState> {
256264
} else {
257265
newParams.push(selectedID);
258266
}
267+
259268
this.submitMultiple(newParams);
260269
};
261270

0 commit comments

Comments
 (0)