Skip to content

Commit

Permalink
fix(blue-print): unable to change index in edit type modal
Browse files Browse the repository at this point in the history
  • Loading branch information
sophieturner0 committed Sep 27, 2024
1 parent 5bcb0f4 commit f6acd73
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Flex>
Expand Down

0 comments on commit f6acd73

Please sign in to comment.