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

Fix Bug where Key wouldn't have last letter of Name when auto generated #27

Merged
merged 1 commit into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/components/flags/FlagForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,12 @@ export default function FlagForm(props: FlagFormProps) {
name="name"
id="name"
handleChange={(e) => {
// remove the character that was just added before comparing
const previousName = formik.values.name.slice(0, -1);

// check if the name and key are currently in sync
// we do this so we don't override a custom key value
if (
isNew &&
(formik.values.key === '' ||
formik.values.key === stringAsKey(previousName))
formik.values.key === stringAsKey(formik.values.name))
) {
formik.setFieldValue(
'key',
Expand Down
5 changes: 1 addition & 4 deletions src/components/segments/SegmentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,12 @@ export default function SegmentForm(props: SegmentFormProps) {
name="name"
id="name"
handleChange={(e) => {
// remove the character that was just added before comparing
const previousName = formik.values.name.slice(0, -1);

// check if the name and key are currently in sync
// we do this so we don't override a custom key value
if (
isNew &&
(formik.values.key === '' ||
formik.values.key === stringAsKey(previousName))
formik.values.key === stringAsKey(formik.values.name))
) {
formik.setFieldValue('key', stringAsKey(e.target.value));
}
Expand Down