Update habitat selector to reset image/zone on habitat change

This commit is contained in:
Dana Lambert 2021-11-05 14:31:32 +13:00
parent f92bb7290c
commit 01a3328ec2

View file

@ -43,11 +43,12 @@ export default function HabitatSelector(props) {
props.setNextDisabled(false); props.setNextDisabled(false);
} }
}); });
const setHabitatImage = (imageId) => { const setHabitatImage = (imageId) => {
// Sets the selected image radio, updates filter state for image and enable the next button // Sets the selected image radio, updates filter state for image and enable the next button
setImageValue(imageId); setImageValue(imageId);
props.updateFilterState({ "habitatImage": imageId }); props.updateFilterState({ "habitatImage": imageId });
props.updateFilterState({ "zone": null });
props.setNextDisabled(false); props.setNextDisabled(false);
} }
@ -55,6 +56,8 @@ export default function HabitatSelector(props) {
// Retrieve and set the value of the radio button // Retrieve and set the value of the radio button
const habitatSelection = event.target.value; const habitatSelection = event.target.value;
setValue(habitatSelection); setValue(habitatSelection);
setHabitatImage(null)
// Set the image default selection if there is only one image variation available // Set the image default selection if there is only one image variation available
const habitatObject = habitatsMap[habitatSelection] const habitatObject = habitatsMap[habitatSelection]