Skip to content

Commit

Permalink
chore(Forms): run fromExternal in all cases
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker committed Dec 23, 2024
1 parent eb86616 commit 6518499
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,33 @@ export default function useExternalValue<Value>(props: Props<Value>) {
if (inIterate && itemPath) {
// This field is inside an iterate, and has a pointer from the base of the element being iterated
if (itemPath === '/') {
return iterateElementValue ?? emptyValue
return (
transformers?.current?.fromExternal?.(
iterateElementValue as Value
) ?? emptyValue
)
}

if (pointer.has(iterateElementValue, itemPath)) {
return pointer.get(iterateElementValue, itemPath) ?? emptyValue
return (
transformers?.current?.fromExternal?.(
pointer.get(iterateElementValue, itemPath) as Value
) ?? emptyValue
)
}
}

if (data && path) {
// There is a surrounding data context and a path for where in the source to find the data
if (path === '/') {
return data ?? emptyValue
return transformers?.current?.fromExternal?.(data) ?? emptyValue
}

if (pointer.has(data, path)) {
return pointer.get(data, path) ?? emptyValue
return (
transformers?.current?.fromExternal?.(pointer.get(data, path)) ??
emptyValue
)
}
}

Expand Down

0 comments on commit 6518499

Please sign in to comment.