Skip to content

Commit

Permalink
fix: update value in popup with period change in timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
BRaimbault committed Feb 28, 2025
1 parent d8657b6 commit b0b4549
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/components/map/layers/ThematicLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,32 @@ class ThematicLayer extends Layer {
)
}

onPeriodChange = (period) => this.setState({ period })
onPeriodChange = (period) => {
this.setState((prevState) => {
const { popup } = prevState
if (!popup) {
return { period }
}

const { valuesByPeriod } = this.props
const newValues = valuesByPeriod[period.id] || {}
const updatedPopup = {
...popup,
feature: {
...popup.feature,
properties: {
...popup.feature.properties,
...newValues[popup.feature.properties.id],
},
},
}

return {
period,
popup: updatedPopup,
}
})
}

onFeatureClick(evt) {
this.setState({ popup: evt })
Expand Down

0 comments on commit b0b4549

Please sign in to comment.