Skip to content
This repository has been archived by the owner on Apr 10, 2023. It is now read-only.

Commit

Permalink
Added a condition with the isNew flag in the handleChange event for t…
Browse files Browse the repository at this point in the history
…he Name input field (#25)
  • Loading branch information
darinmclain authored Jan 13, 2023
1 parent be59ba4 commit a24da74
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/components/flags/FlagForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ export default function FlagForm(props: FlagFormProps) {
// check if the name and key are currently in sync
// we do this so we don't override a custom key value
if (
formik.values.key === '' ||
formik.values.key === stringAsKey(previousName)
isNew &&
(formik.values.key === '' ||
formik.values.key === stringAsKey(previousName))
) {
formik.setFieldValue(
'key',
Expand Down
5 changes: 3 additions & 2 deletions src/components/segments/SegmentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ export default function SegmentForm(props: SegmentFormProps) {
// check if the name and key are currently in sync
// we do this so we don't override a custom key value
if (
formik.values.key === '' ||
formik.values.key === stringAsKey(previousName)
isNew &&
(formik.values.key === '' ||
formik.values.key === stringAsKey(previousName))
) {
formik.setFieldValue('key', stringAsKey(e.target.value));
}
Expand Down

0 comments on commit a24da74

Please sign in to comment.