@@ -38,7 +38,7 @@ export type FormContext<T extends ConfigurableProps> = {
3838 setSubmitting : ( submitting : boolean ) => void ;
3939 submitting : boolean ;
4040 userId : string ;
41- isDevelopment : boolean ;
41+ enableDebugging : boolean ;
4242} ;
4343
4444export const skippablePropTypes = [
@@ -75,7 +75,7 @@ export const FormContextProvider = <T extends ConfigurableProps>({
7575 const id = useId ( ) ;
7676
7777 const {
78- component, configuredProps : __configuredProps , propNames, userId, sdkErrors : __sdkErrors , environment ,
78+ component, configuredProps : __configuredProps , propNames, userId, sdkErrors : __sdkErrors , enableDebugging : __enableDebugging ,
7979 } = formProps ;
8080 const componentId = component . key ;
8181
@@ -102,9 +102,9 @@ export const FormContextProvider = <T extends ConfigurableProps>({
102102 ] = useState < Record < string , string > [ ] > ( [ ] )
103103
104104 const [
105- isDevelopment ,
106- setIsDevelopment ,
107- ] = useState < boolean > ( environment === "development" )
105+ enableDebugging ,
106+ setEnableDebugging ,
107+ ] = useState < boolean > ( __enableDebugging === true )
108108
109109 const [
110110 enabledOptionalProps ,
@@ -159,16 +159,14 @@ export const FormContextProvider = <T extends ConfigurableProps>({
159159 const {
160160 dynamicProps, observations, errors : __errors ,
161161 } = result
162- const errorsAndObservations = [ ]
163- if ( observations ) {
164- errorsAndObservations . push ( ...observations )
165- }
166- if ( __errors ) {
167- errorsAndObservations . push ( ...__errors )
168- }
169- if ( errorsAndObservations ) {
170- handleSdkErrors ( errorsAndObservations )
162+
163+ // Prioritize errors from observations over the errors array
164+ if ( observations && observations . filter ( ( o ) => o . k === "error" ) . length > 0 ) {
165+ handleSdkErrors ( observations )
166+ } else {
167+ handleSdkErrors ( __errors )
171168 }
169+
172170 // XXX what about if null?
173171 // TODO observation errors, etc.
174172 if ( dynamicProps ) {
@@ -549,7 +547,7 @@ export const FormContextProvider = <T extends ConfigurableProps>({
549547 setSubmitting,
550548 submitting,
551549 sdkErrors,
552- isDevelopment ,
550+ enableDebugging ,
553551 } ;
554552 return < FormContext . Provider value = { value } > { children } </ FormContext . Provider > ;
555553} ;
0 commit comments