diff --git a/src/app/components/building-passport/RecommendationCard.tsx b/src/app/components/building-passport/RecommendationCard.tsx index fb06508..52f8575 100644 --- a/src/app/components/building-passport/RecommendationCard.tsx +++ b/src/app/components/building-passport/RecommendationCard.tsx @@ -56,7 +56,9 @@ export function RecommendationModal({ const [saveButtonDisabled, setSaveButtonDisabled] = useState(true); // Find the row where default is true - const defaultRowIndex = recommendationData.findIndex((d) => d.default); + const [defaultRowIndex, setDefaultRowIndex] = useState( + recommendationData.findIndex((d) => d.default) + ); // Initialise the state with the default row index const [rowSelection, setRowSelection] = useState( @@ -78,6 +80,8 @@ export function RecommendationModal({ const newIndex = parseInt(Object.keys(rowSelection)[0]); setCardComponent(recommendationData[newIndex]); + // Set the default index + setDefaultRowIndex(newIndex); } return (