Skip to content

Commit

Permalink
1-1315: revalidate feature name whenever the project changes (#4628)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
thomasheartman committed Sep 7, 2023
1 parent 15015f7 commit 90395b9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions frontend/src/component/feature/FeatureForm/FeatureForm.tsx
Expand Up @@ -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>
Expand Down

0 comments on commit 90395b9

Please sign in to comment.