From 95492048f7b7398fbfa26bc4eb66b5de97e13724 Mon Sep 17 00:00:00 2001 From: kaulfield23 Date: Mon, 18 Sep 2023 09:55:52 +0200 Subject: [PATCH] setText when user creates new event type --- src/features/events/components/EventTypeAutocomplete.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/features/events/components/EventTypeAutocomplete.tsx b/src/features/events/components/EventTypeAutocomplete.tsx index cafdd5f824..7cee850f09 100644 --- a/src/features/events/components/EventTypeAutocomplete.tsx +++ b/src/features/events/components/EventTypeAutocomplete.tsx @@ -89,8 +89,9 @@ const EventTypeAutocomplete: FC = ({ //In here, when the length of the type changes, //it searches for the created event and updates event with an ID. if (createdType !== '') { - const newId = types.find((item) => item.title === createdType)!.id; - onChangeNewOption(newId!); + const newEventType = types.find((item) => item.title === createdType); + setText(newEventType!.title); + onChangeNewOption(newEventType!.id); } }, [types.length]); @@ -234,7 +235,7 @@ const EventTypeAutocomplete: FC = ({ ? value : { id: 'UNCATEGORIZED', - title: text !== '' ? text : uncategorizedMsg, + title: text, } } />