Skip to content

Commit

Permalink
Merge pull request #1205 from visualize-admin/fix/published-interacti…
Browse files Browse the repository at this point in the history
…ve-filters-infinite-loading

fix: Infinite loading of cascading filters
  • Loading branch information
bprusinowski authored Oct 6, 2023
2 parents e15de35 + 1e942da commit 539249a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ You can also check the [release page](https://github.com/visualize-admin/visuali

## Unreleased

Nothing yet.
- Fixes
- Cascading filters are not stuck anymore in the loading mode in some cases

# [3.22.8] - 2023-09-29

Expand Down
17 changes: 9 additions & 8 deletions app/charts/shared/chart-data-filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import {
useInteractiveFiltersRaw,
} from "@/stores/interactive-filters";
import { hierarchyToOptions } from "@/utils/hierarchy";
import useEvent from "@/utils/use-event";

type ChartDataFiltersProps = {
dataSet: string;
Expand Down Expand Up @@ -227,11 +228,11 @@ const DataFilter = (props: DataFilterProps) => {
const dimension = data?.dataCubeByIri?.dimensionByIri;
const hierarchy = data?.dataCubeByIri?.dimensionByIri?.hierarchy;

const setDataFilter = (
e: SelectChangeEvent<unknown> | { target: { value: string } }
) => {
updateDataFilter(dimensionIri, e.target.value as string);
};
const setDataFilter = useEvent(
(e: SelectChangeEvent<unknown> | { target: { value: string } }) => {
updateDataFilter(dimensionIri, e.target.value as string);
}
);

const configFilter = dimension
? chartConfig.filters[dimension.iri]
Expand Down Expand Up @@ -263,9 +264,9 @@ const DataFilter = (props: DataFilterProps) => {
dimension?.values,
dimensionIri,
fetching,
updateDataFilter,
// Also reload when the config value changes.
setDataFilter,
configFilterValue,
updateDataFilter,
]);

return dimension ? (
Expand Down Expand Up @@ -603,7 +604,7 @@ const useEnsurePossibleInteractiveFilters = (

// We need to get the values dynamically, as they can get updated by
// useSyncInteractiveFilters and this callback runs with old value.
const dataFilters = IFRaw.getState().dataFilters;
const dataFilters = { ...IFRaw.getState().dataFilters };

if (!isEqual(filters, interactiveFilters) && !isEmpty(filters)) {
for (const [k, v] of Object.entries(filters)) {
Expand Down

1 comment on commit 539249a

@vercel
Copy link

@vercel vercel bot commented on 539249a Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

visualization-tool – ./

visualization-tool-git-main-ixt1.vercel.app
visualization-tool-ixt1.vercel.app
visualization-tool-alpha.vercel.app

Please sign in to comment.