Skip to content

Commit

Permalink
preserve demographic view when switching between single years
Browse files Browse the repository at this point in the history
  • Loading branch information
macfarlandian committed Nov 17, 2020
1 parent c846614 commit f8c38cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion public-dashboard-client/src/page-prison/PagePrison.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ export default function PagePrison() {
// doing this inside the render loop rather than in an effect
// to prevent an intermediate state from flashing on the chart;
// the current value check avoids an infinite render loop
if (!singleCohortSelected && recidivismDimension !== DIMENSION_KEYS.total) {
if (
!singleCohortSelected &&
// we don't need to reset the dimension if no cohorts are selected
selectedCohorts.length > 1 &&
recidivismDimension !== DIMENSION_KEYS.total
) {
setRecidivismDimension(DIMENSION_KEYS.total);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function prepareChartData({
}) {
const showDemographics =
selectedCohorts &&
selectedCohorts.length === 1 &&
selectedCohorts.length <= 1 &&
dimension !== DIMENSION_KEYS.total;

const filteredData = data.filter(recordIsTotalByDimension(dimension));
Expand Down

0 comments on commit f8c38cc

Please sign in to comment.