@@ -404,26 +404,18 @@ function EditingTypeChangeSourceLayerSource(props: {
404404 props . pendingChanges . find ( ( change ) => change . operationId === props . userEditOperation . id ) ?. sourceLayerType ||
405405 props . userEditOperation . currentValues . type
406406 )
407- const [ schemaValues , setSchemaValues ] = React . useState ( {
408- type : selectedSourceGroup ,
409- values :
410- props . pendingChanges . find ( ( change ) => change . operationId === props . userEditOperation . id ) ?. value ||
411- props . userEditOperation . currentValues . value ,
412- } )
413-
414- const selectedSourceObject = Object . values < UserEditingSourceLayer > ( props . userEditOperation . schemas ) . find (
415- ( layer ) => layer . sourceLayerType === selectedSourceGroup
407+ const [ selectedValues , setSelectedValues ] = React . useState < Record < string , string > > (
408+ props . pendingChanges . find ( ( change ) => change . operationId === props . userEditOperation . id ) ?. value ||
409+ props . userEditOperation . currentValues . value
416410 )
417- const jsonSchema = selectedSourceObject ?. schema
418- const schema = jsonSchema ? JSONBlobParse ( jsonSchema ) : undefined
419411
420- const groups = clone ( props . userEditOperation . schemas ) || { }
412+ const jsonSchema = Object . values < UserEditingSourceLayer > ( props . userEditOperation . schemas ) . find (
413+ ( layer ) => layer . sourceLayerType === selectedSourceGroup
414+ ) ?. schema
415+ const selectedGroupSchema = jsonSchema ? JSONBlobParse ( jsonSchema ) : undefined
421416
422417 const handleSourceChange = ( ) => {
423- setSchemaValues ( {
424- type : selectedSourceGroup ,
425- values : schemaValues . values ,
426- } )
418+ setSelectedValues ( selectedValues )
427419 // Add to pending changes instead of executing immediately
428420 props . setPendingChanges ( ( prev ) => {
429421 const filtered = prev . filter (
@@ -434,12 +426,11 @@ function EditingTypeChangeSourceLayerSource(props: {
434426 )
435427 )
436428 // Only use the key,value pair from the selected source group:
437- const newKey = Object . keys ( schemaValues . values ) . find ( ( key ) => {
429+ const newKey = Object . keys ( props . userEditOperation . schemas ) . find ( ( key ) => {
438430 return props . userEditOperation . schemas [ key ] . sourceLayerType === selectedSourceGroup
439431 } )
440432 if ( ! newKey ) return filtered
441- const newValue = props . userEditOperation . currentValues . value [ newKey ]
442-
433+ const newValue = selectedValues [ newKey ]
443434 return [
444435 ...filtered ,
445436 {
@@ -455,7 +446,7 @@ function EditingTypeChangeSourceLayerSource(props: {
455446 return (
456447 < >
457448 < div className = "propertiespanel-pop-up__groupselector" >
458- { Object . values < UserEditingSourceLayer > ( groups ) . map ( ( group , index ) => {
449+ { Object . values < UserEditingSourceLayer > ( props . userEditOperation . schemas ) . map ( ( group , index ) => {
459450 return (
460451 < button
461452 className = { classNames (
@@ -474,12 +465,12 @@ function EditingTypeChangeSourceLayerSource(props: {
474465 )
475466 } ) }
476467 </ div >
477- { schema && (
478- < div onClick = { handleSourceChange } >
468+ { selectedGroupSchema && (
469+ < div onChange = { handleSourceChange } >
479470 < a className = "propertiespanel-pop-up__label" > { t ( 'Source' ) } :</ a >
480471 < SchemaFormInPlace
481- schema = { schema }
482- object = { schemaValues . values }
472+ schema = { selectedGroupSchema }
473+ object = { selectedValues }
483474 translationNamespaces = { props . userEditOperation . translationNamespaces }
484475 />
485476 < br />
0 commit comments