diff --git a/map-view/src/components/FeatureInfo.tsx b/map-view/src/components/FeatureInfo.tsx index 3dba94e2..b05bd078 100644 --- a/map-view/src/components/FeatureInfo.tsx +++ b/map-view/src/components/FeatureInfo.tsx @@ -44,6 +44,7 @@ interface FeatureInfoProps extends WithStyles, WithTranslation { interface FeatureInfoState { featureIndex: number; realPlanDistance?: number; + features: Feature[]; } class FeatureInfo extends React.Component { @@ -52,9 +53,17 @@ class FeatureInfo extends React.Component { this.state = { featureIndex: 0, realPlanDistance: undefined, + features: props.features, }; } + static getDerivedStateFromProps(props: FeatureInfoProps, state: FeatureInfoState) { + if (props.features !== state.features) { + return { featureIndex: 0, realPlanDistance: undefined, features: props.features }; + } + return null; + } + getAdminLink(feature: Feature) { const app_name = feature["app_name"]; const fid = feature["id_"]; @@ -78,6 +87,7 @@ class FeatureInfo extends React.Component { const { features, classes, onClose, t } = this.props; const { featureIndex } = this.state; const feature = features[featureIndex]; + const fid = feature["id_"]; const featureType = fid.split(".")[0]; const {