From 90395b974b1c7a8556ab30f390b9edf05bd336d2 Mon Sep 17 00:00:00 2001 From: Thomas Heartman Date: Thu, 7 Sep 2023 09:15:59 +0200 Subject: [PATCH] 1-1315: revalidate feature name whenever the project changes (#4628) This change makes it so that the flag name is revalidated against the new project pattern whenever you change the target project for a flag. The validation is not run if the name is empty, if there is no pattern, or if there is no validation method. This solves the case where you input a name, then change the project, and where the name isn't valid for the new project. Previously, it wouldn't revalidate, but now it does. --- frontend/src/component/feature/FeatureForm/FeatureForm.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frontend/src/component/feature/FeatureForm/FeatureForm.tsx b/frontend/src/component/feature/FeatureForm/FeatureForm.tsx index 79928e2aed..6d04ff836f 100644 --- a/frontend/src/component/feature/FeatureForm/FeatureForm.tsx +++ b/frontend/src/component/feature/FeatureForm/FeatureForm.tsx @@ -138,6 +138,13 @@ const FeatureForm: React.FC = ({ const displayFeatureNamingInfo = Boolean(featureNaming?.pattern); + React.useEffect(() => { + if (featureNaming?.pattern && validateToggleName && name) { + clearErrors(); + validateToggleName(); + } + }, [featureNaming?.pattern]); + return (