diff --git a/studio-test/src/dependencies/custom-components/Address.tsx b/studio-test/src/dependencies/custom-components/Address.tsx index 17dde45a99..f629f3bcfd 100644 --- a/studio-test/src/dependencies/custom-components/Address.tsx +++ b/studio-test/src/dependencies/custom-components/Address.tsx @@ -1,5 +1,5 @@ import { AsyncSelect } from 'chakra-react-select' -import React, {useState} from 'react' +import React, {useEffect, useState} from 'react' import axios from 'axios' import {debounce} from 'lodash' import lodash from 'lodash' @@ -13,6 +13,12 @@ const Address = ({children, onChange, value, isCityOnly, ...props}: {children: R props.setComponentAttribute(props.id, props.attribute) } + useEffect(() => { + if (props.setComponentValue) { + props.setComponentValue(props.id, address) + } + }, [address]) + const addressToOption = addr => { return addr ? ({value: addr, label : isCityOnly ? addr.city : `${addr.address}, ${addr.zip_code} ${addr.city}`}) diff --git a/studio-test/src/dependencies/hoc/withDynamicInput.js b/studio-test/src/dependencies/hoc/withDynamicInput.js index b98b0e820b..f32d7b4a18 100644 --- a/studio-test/src/dependencies/hoc/withDynamicInput.js +++ b/studio-test/src/dependencies/hoc/withDynamicInput.js @@ -96,13 +96,13 @@ const withDynamicInput = Component => { ) : - () + () } return displayEye ? withDisplayEye(Component) : - + } return Internal diff --git a/studio/src/dependencies/custom-components/Address.tsx b/studio/src/dependencies/custom-components/Address.tsx index 17dde45a99..f629f3bcfd 100644 --- a/studio/src/dependencies/custom-components/Address.tsx +++ b/studio/src/dependencies/custom-components/Address.tsx @@ -1,5 +1,5 @@ import { AsyncSelect } from 'chakra-react-select' -import React, {useState} from 'react' +import React, {useEffect, useState} from 'react' import axios from 'axios' import {debounce} from 'lodash' import lodash from 'lodash' @@ -13,6 +13,12 @@ const Address = ({children, onChange, value, isCityOnly, ...props}: {children: R props.setComponentAttribute(props.id, props.attribute) } + useEffect(() => { + if (props.setComponentValue) { + props.setComponentValue(props.id, address) + } + }, [address]) + const addressToOption = addr => { return addr ? ({value: addr, label : isCityOnly ? addr.city : `${addr.address}, ${addr.zip_code} ${addr.city}`}) diff --git a/studio/src/dependencies/hoc/withDynamicInput.js b/studio/src/dependencies/hoc/withDynamicInput.js index b98b0e820b..f32d7b4a18 100644 --- a/studio/src/dependencies/hoc/withDynamicInput.js +++ b/studio/src/dependencies/hoc/withDynamicInput.js @@ -96,13 +96,13 @@ const withDynamicInput = Component => { ) : - () + () } return displayEye ? withDisplayEye(Component) : - + } return Internal