@@ -2746,10 +2746,20 @@ export default class StageStore implements IStageStore {
2746
2746
const actionParams : ElementsActionParam [ ] = [ ] ;
2747
2747
const result : IElement [ ] = [ ] ;
2748
2748
const models = ElementUtils . convertElementsJson ( elementsJson ) ;
2749
+ const groupModelIds : Set < string > = new Set ( ) ;
2750
+ models . forEach ( model => {
2751
+ if ( model . type === CreatorTypes . group ) {
2752
+ groupModelIds . add ( model . id ) ;
2753
+ }
2754
+ } ) ;
2755
+ let newSubIds : string [ ] = [ ] ;
2749
2756
for ( const model of models ) {
2750
2757
await ElementUtils . convertElementModel ( model ) ;
2751
2758
model . name = `${ CreatorHelper . getCreatorByType ( model . type ) . name } ${ this . _increaseElementSerialNumber ( model . type ) } ` ;
2752
- model . groupId = targetGroupId ;
2759
+ if ( ! groupModelIds . has ( model . groupId ) ) {
2760
+ model . groupId = targetGroupId ;
2761
+ newSubIds . push ( model . id ) ;
2762
+ }
2753
2763
const element = this . insertAfterElementByModel ( model , targetElement ) ;
2754
2764
actionParams . push ( {
2755
2765
type : ElementActionTypes . Added ,
@@ -2767,11 +2777,10 @@ export default class StageStore implements IStageStore {
2767
2777
}
2768
2778
await actionUndoCallback ( actionParams ) ;
2769
2779
if ( targetGroup ) {
2770
- const elementIds = result . map ( element => element . id ) ;
2771
2780
if ( targetIndexOfGroupSubs > - 1 ) {
2772
- targetSubIds . splice ( targetIndexOfGroupSubs + 1 , 0 , ...elementIds ) ;
2781
+ targetSubIds . splice ( targetIndexOfGroupSubs + 1 , 0 , ...newSubIds ) ;
2773
2782
} else {
2774
- targetSubIds . push ( ...elementIds ) ;
2783
+ targetSubIds . push ( ...newSubIds ) ;
2775
2784
}
2776
2785
this . updateElementModel ( targetGroupId , { subIds : targetSubIds } ) ;
2777
2786
targetGroup . refreshBySubs ( ) ;
0 commit comments