Skip to content

Commit

Permalink
fix: Fixes error where values specified as a list in a creature were …
Browse files Browse the repository at this point in the history
…not being filtered correctly in the encounter builder
  • Loading branch information
valentine195 committed May 3, 2024
1 parent 63d8136 commit a395715
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/builder/stores/filter/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,13 @@ const createOptionsFilter: FilterFactory<OptionsFilter> = (filter) => {
subscribe,
set,
reset: () => set([]),
compare: (value: number | string) => {
compare: (value: number | string | Array<string>) => {
if (get(isDefault)) return true;
if (typeof value === "number") return false;
const values = get(store);
if (Array.isArray(value)) {
return value.some((v) => values.includes(v));
}
return values.includes(value);
},
update,
Expand Down Expand Up @@ -211,7 +214,13 @@ function getDerivedFilterOptions(
break;
}
case FilterType.Options: {
options.get(filter).add(creature[field]);
if (Array.isArray(creature[field])) {
for (const value of creature[field]) {
options.get(filter).add(value);
}
} else if (typeof creature[field] === "string") {
options.get(filter).add(creature[field]);
}
break;
}
case FilterType.Search: {
Expand Down

0 comments on commit a395715

Please sign in to comment.