Skip to content

Commit

Permalink
Merge pull request #2246 from sophieturner0/Unable-Change-Index
Browse files Browse the repository at this point in the history
Fixed[BluePrint]: Unable to Change `Index` After Selecting From Dropdown in `Edit Type` Modal
  • Loading branch information
Rassl authored Oct 8, 2024
2 parents e368609 + 6628a2b commit 292d9e9
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -462,23 +462,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])

const IconComponent = Icons[selectedIcon as keyof typeof Icons]

Expand Down

0 comments on commit 292d9e9

Please sign in to comment.