File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,16 +39,15 @@ import {
3939function Edit ( { attributes, setAttributes, isSelected } ) {
4040 const { consts } = attributes ;
4141 const [ isOpen , setIsOpen ] = useState ( false ) ;
42- const [ configList , updateConfigList ] = useState ( Object . entries ( consts ) ) ;
42+ const [ configList , updateConfigList ] = useState ( Object . entries ( consts || { } ) ) ;
4343 const [ selectedConfig , setSelectedConfig ] = useState ( undefined ) ;
4444
4545 useEffect ( ( ) => {
46- setAttributes ( { consts : keyValuePairsToObject ( configList ) } ) ;
47-
48- if ( ! isSelected ) {
49- handleClose ( ) ;
46+ const configObject = keyValuePairsToObject ( configList ) ;
47+ if ( JSON . stringify ( consts ) !== JSON . stringify ( configObject ) ) {
48+ setAttributes ( { consts : configObject } ) ;
5049 }
51- } , [ configList , isSelected ] ) ;
50+ } , [ configList ] ) ;
5251
5352 const addConfig = ( ) => {
5453 addKeyValuePair ( configList , updateConfigList ) ;
Original file line number Diff line number Diff line change @@ -40,16 +40,15 @@ import {
4040function Edit ( { attributes, setAttributes, isSelected } ) {
4141 const { meta, userId } = attributes ;
4242 const [ isOpen , setIsOpen ] = useState ( false ) ;
43- const [ metaList , updateMetaList ] = useState ( Object . entries ( meta ) ) ;
43+ const [ metaList , updateMetaList ] = useState ( Object . entries ( meta || { } ) ) ;
4444 const [ selectedMeta , setSelectedMeta ] = useState ( undefined ) ;
4545
4646 useEffect ( ( ) => {
47- setAttributes ( { meta : keyValuePairsToObject ( metaList ) } ) ;
48-
49- if ( ! isSelected ) {
50- handleClose ( ) ;
47+ const metaObject = keyValuePairsToObject ( metaList ) ;
48+ if ( JSON . stringify ( meta ) !== JSON . stringify ( metaObject ) ) {
49+ setAttributes ( { meta : metaObject } ) ;
5150 }
52- } , [ metaList , isSelected ] ) ;
51+ } , [ metaList ] ) ;
5352
5453 const addOption = ( ) => {
5554 addKeyValuePair ( metaList , updateMetaList ) ;
You can’t perform that action at this time.
0 commit comments