Skip to content

Commit

Permalink
Merge pull request #71 from concord-consortium/188345477-fix-dataset-…
Browse files Browse the repository at this point in the history
…attribute-loading

fix: Dataset views not loading saved attribute [PT-188345477]
  • Loading branch information
dougmartin authored Sep 27, 2024
2 parents d730a40 + 58360df commit 1a71fe0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/hooks/use-codap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ export const useCODAP = ({onCODAPDataChanged, getGraph, setGraph, setInitialGrap
}]);
};

const handleDataChanged = useCallback(async ({datasetName, collectionName, attributeName}: CODAPAttribute) => {
const handleDataChanged = useCallback(async (codapAttribute: CODAPAttribute, viewModeOverride?: ViewMode ) => {
const {datasetName, collectionName, attributeName} = codapAttribute;
const values = await getValuesForAttribute(datasetName, collectionName, attributeName);
const valuesChanged = !valuesRef.current || (JSON.stringify(values) !== JSON.stringify(valuesRef.current));
if (viewMode === "dataset" && valuesChanged) {
const currentViewMode = viewModeOverride ?? viewMode;
if (currentViewMode === "dataset" && valuesChanged) {
onCODAPDataChanged(values);
valuesRef.current = values;
}
Expand All @@ -100,7 +102,7 @@ export const useCODAP = ({onCODAPDataChanged, getGraph, setGraph, setInitialGrap
} else {
if (values?.attribute) {
setAttribute(values.attribute);
handleDataChanged(values.attribute);
handleDataChanged(values.attribute, values.viewMode);
}
}
}
Expand Down

0 comments on commit 1a71fe0

Please sign in to comment.