Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Hierarchical cascading filters #1177

Merged
merged 3 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ You can also check the [release page](https://github.com/visualize-admin/visuali

- Fixes
- Table docs now work correctly again
- Cascading mode now works correctly for hierarchical dimensions used as interactive filters
- Changing the locale when previewing a larger cube no longer triggers multiple locale switches

# [3.22.5] - 2023-09-12
Expand Down
5 changes: 4 additions & 1 deletion app/charts/shared/chart-data-filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,10 @@ const DataFilterHierarchyDimension = (
const options = React.useMemo(() => {
let opts = [] as { label: string; value: string; isNoneValue?: boolean }[];
if (hierarchy) {
opts = hierarchyToOptions(hierarchy);
opts = hierarchyToOptions(
hierarchy,
dimensionValues.map((d) => d.value)
);
} else {
// @ts-ignore
opts = dimensionValues;
Expand Down
4 changes: 2 additions & 2 deletions app/utils/hierarchy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ascending } from "d3";

import { SelectTreeProps } from "@/components/select-tree";
import { OptionGroup, Option } from "@/configurator";
import { Option, OptionGroup } from "@/configurator";
import { HierarchyParents } from "@/configurator/components/use-hierarchy-parents";
import { DimensionValue } from "@/domain/data";
import { truthy } from "@/domain/types";
Expand Down Expand Up @@ -36,7 +36,7 @@ export const makeOptionGroups = (

export const hierarchyToOptions = (
hierarchy: HierarchyValue[],
possibleValues?: DimensionValue["value"][]
possibleValues: DimensionValue["value"][]
) => {
const possibleValuesSet = possibleValues
? new Set(possibleValues)
Expand Down