🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Enhance GoalFormModal to reinitialize properties on modal open
Bill Yang12329dc538a0
diff --git a/client/src/app/[site]/goals/components/GoalFormModal.tsx b/client/src/app/[site]/goals/components/GoalFormModal.tsxindex f0275bf61..2e26293ab 100644--- a/client/src/app/[site]/goals/components/GoalFormModal.tsx+++ b/client/src/app/[site]/goals/components/GoalFormModal.tsx@@ -2,7 +2,7 @@import { zodResolver } from "@hookform/resolvers/zod";import { FileText, MousePointerClick } from "lucide-react";-import { useState } from "react";+import { useState, useEffect } from "react";import { useForm } from "react-hook-form";import * as z from "zod";import { useCreateGoal } from "../../../../api/analytics/goals/useCreateGoal";@@ -75,6 +75,15 @@ export default function GoalFormModal({!!goal?.config.eventPropertyKey && !!goal?.config.eventPropertyValue);+ // Reinitialize useProperties when goal changes or modal opens+ useEffect(() => {+ if (isOpen) {+ setUseProperties(+ !!goal?.config.eventPropertyKey && !!goal?.config.eventPropertyValue+ );+ }+ }, [isOpen, goal?.config.eventPropertyKey, goal?.config.eventPropertyValue]);+const onClose = () => {setIsOpen(false);};