From f6acd73b869c4531f7574762d0d68fa7089636ed Mon Sep 17 00:00:00 2001 From: Sophie Turner Date: Fri, 27 Sep 2024 15:37:46 +0500 Subject: [PATCH] fix(blue-print): unable to change index in edit type modal --- .../BlueprintModal/Body/Editor/index.tsx | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/components/ModalsContainer/BlueprintModal/Body/Editor/index.tsx b/src/components/ModalsContainer/BlueprintModal/Body/Editor/index.tsx index 03df72858..abe4f29a4 100644 --- a/src/components/ModalsContainer/BlueprintModal/Body/Editor/index.tsx +++ b/src/components/ModalsContainer/BlueprintModal/Body/Editor/index.tsx @@ -436,23 +436,27 @@ export const Editor = ({ return undefined }, [parent, selectedSchema, selectedNodeParentOptions]) + const selectedIndex = watch('selectedIndex') + const resolvedSelectedIndexValue = useMemo((): TAutocompleteOption | undefined => { - if (!selectedSchema) { - return undefined + if (selectedIndex) { + return { label: selectedIndex, value: selectedIndex } } - const option = attributes.find((attr) => attr.key === selectedSchema.index) + if (selectedSchema) { + const option = attributes.find((attr) => attr.key === selectedSchema.index) - if (option) { - return { label: option.key, value: option.key } - } + if (option) { + return { label: option.key, value: option.key } + } - if (selectedSchema.index) { - return { label: selectedSchema.index, value: selectedSchema.index } + if (selectedSchema.index) { + return { label: selectedSchema.index, value: selectedSchema.index } + } } return undefined - }, [selectedSchema, attributes]) + }, [selectedSchema, attributes, selectedIndex]) return (