@@ -73,7 +73,7 @@ function AddressPage({privatePersonalDetails, country}) {
73
73
74
74
const address = lodashGet ( privatePersonalDetails , 'address' ) || { } ;
75
75
const [ street1 , street2 ] = ( address . street || '' ) . split ( '\n' ) ;
76
-
76
+ const [ state , setState ] = useState ( address . state ) ;
77
77
/**
78
78
* @param {Function } translate - translate function
79
79
* @param {Boolean } isUSAForm - selected country ISO code is US
@@ -120,10 +120,15 @@ function AddressPage({privatePersonalDetails, country}) {
120
120
} , [ ] ) ;
121
121
122
122
const handleAddressChange = ( value , key ) => {
123
- if ( key !== 'country' ) {
123
+ if ( key !== 'country' && key !== 'state' ) {
124
+ return ;
125
+ }
126
+ if ( key === 'country' ) {
127
+ setCurrentCountry ( value ) ;
128
+ setState ( '' ) ;
124
129
return ;
125
130
}
126
- setCurrentCountry ( value ) ;
131
+ setState ( value ) ;
127
132
} ;
128
133
129
134
if ( lodashGet ( privatePersonalDetails , 'isLoading' , true ) ) {
@@ -186,7 +191,8 @@ function AddressPage({privatePersonalDetails, country}) {
186
191
< View style = { styles . mhn5 } >
187
192
< StatePicker
188
193
inputID = "state"
189
- defaultValue = { address . state }
194
+ defaultValue = { state }
195
+ onValueChange = { handleAddressChange }
190
196
/>
191
197
</ View >
192
198
) : (
@@ -195,9 +201,10 @@ function AddressPage({privatePersonalDetails, country}) {
195
201
label = { translate ( 'common.stateOrProvince' ) }
196
202
accessibilityLabel = { translate ( 'common.stateOrProvince' ) }
197
203
accessibilityRole = { CONST . ACCESSIBILITY_ROLE . TEXT }
198
- defaultValue = { address . state || '' }
204
+ value = { state || '' }
199
205
maxLength = { CONST . FORM_CHARACTER_LIMIT }
200
206
spellCheck = { false }
207
+ onValueChange = { handleAddressChange }
201
208
/>
202
209
) }
203
210
< View style = { styles . formSpaceVertical } />
0 commit comments