diff --git a/src/Components/Editor/Actions/ContainerOperations.ts b/src/Components/Editor/Actions/ContainerOperations.ts index 9b2b460..104eb04 100644 --- a/src/Components/Editor/Actions/ContainerOperations.ts +++ b/src/Components/Editor/Actions/ContainerOperations.ts @@ -6,7 +6,7 @@ import { GetCurrentHistory, UpdateCounters } from '../Editor'; import { AddMethod } from '../../../Enums/AddMethod'; import { IAvailableContainer } from '../../../Interfaces/IAvailableContainer'; import { GetDefaultContainerProps, DEFAULTCHILDTYPE_ALLOW_CYCLIC, DEFAULTCHILDTYPE_MAX_DEPTH } from '../../../utils/default'; -import { ApplyBehaviors } from '../Behaviors/Behaviors'; +import { ApplyBehaviors, ApplyBehaviorsOnSiblings } from '../Behaviors/Behaviors'; import { ISymbolModel } from '../../../Interfaces/ISymbolModel'; import Swal from 'sweetalert2'; import { ApplyMargin, TransformX } from '../../../utils/svg'; @@ -626,19 +626,3 @@ function LinkSymbol( newSymbol.linkedContainers.add(containerId); } - -/** - * Iterate over the siblings of newContainer and apply the behaviors - * @param newContainer - * @param symbols - * @returns - */ -function ApplyBehaviorsOnSiblings(newContainer: ContainerModel, symbols: Map): void { - if (newContainer.parent === null || newContainer.parent === undefined) { - return; - } - - newContainer.parent.children - .filter(container => newContainer !== container) - .forEach(container => ApplyBehaviors(container, symbols)); -} diff --git a/src/Components/Editor/Actions/SymbolOperations.ts b/src/Components/Editor/Actions/SymbolOperations.ts index e3c89fa..9504c55 100644 --- a/src/Components/Editor/Actions/SymbolOperations.ts +++ b/src/Components/Editor/Actions/SymbolOperations.ts @@ -1,4 +1,3 @@ -import { Dispatch, SetStateAction } from 'react'; import { IConfiguration } from '../../../Interfaces/IConfiguration'; import { IContainerModel } from '../../../Interfaces/IContainerModel'; import { IHistoryState } from '../../../Interfaces/IHistoryState'; @@ -6,7 +5,7 @@ import { ISymbolModel } from '../../../Interfaces/ISymbolModel'; import { GetDefaultSymbolModel } from '../../../utils/default'; import { FindContainerById } from '../../../utils/itertools'; import { RestoreX } from '../../../utils/svg'; -import { ApplyBehaviors } from '../Behaviors/Behaviors'; +import { ApplyBehaviors, ApplyBehaviorsOnSiblings } from '../Behaviors/Behaviors'; import { GetCurrentHistory, UpdateCounters } from '../Editor'; export function AddSymbol( @@ -150,6 +149,8 @@ export function OnPropertyChange( } ApplyBehaviors(container, newSymbols); + + ApplyBehaviorsOnSiblings(container, newSymbols); }); history.push({ diff --git a/src/Components/Editor/Behaviors/Behaviors.ts b/src/Components/Editor/Behaviors/Behaviors.ts index 928f25d..feae69e 100644 --- a/src/Components/Editor/Behaviors/Behaviors.ts +++ b/src/Components/Editor/Behaviors/Behaviors.ts @@ -35,3 +35,19 @@ export function ApplyBehaviors(container: IContainerModel, symbols: Map): void { + if (newContainer.parent === null || newContainer.parent === undefined) { + return; + } + + newContainer.parent.children + .filter(container => newContainer !== container) + .forEach(container => ApplyBehaviors(container, symbols)); +}