1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-31 00:16:47 +01:00

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.
This commit is contained in:
Thomas Heartman 2023-09-07 09:15:59 +02:00 committed by GitHub
parent 15015f78f3
commit 90395b974b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -138,6 +138,13 @@ const FeatureForm: React.FC<IFeatureToggleForm> = ({
const displayFeatureNamingInfo = Boolean(featureNaming?.pattern);
React.useEffect(() => {
if (featureNaming?.pattern && validateToggleName && name) {
clearErrors();
validateToggleName();
}
}, [featureNaming?.pattern]);
return (
<StyledForm onSubmit={handleSubmit}>
<StyledContainer>