Trouble with layout after grouping

+1 vote
asked Sep 30, 2019 in Question / help by japearson (120 points)

I have discovered a weird issue, where if you put a grouping around some objects then it ignores or at least de-prioritises the placement of the objects.  This is a minimal set that creates the problem. In the diagram below, input should be on the left and output on the right, but they both end up on the right, with the grouping.

@startuml
rectangle "Group Header" as GH {
    rectangle "Group Rect 1" as AM
    rectangle "Group Rect 2" as RECT2
}
rectangle "Input" as INPT
rectangle "Output" as OUT
rectangle "Common Output" as COUT

INPT -right-> RECT2
RECT2 -right-> OUT
RECT2 -up-> AM
RECT2 -up-> COUT
AM -up-> COUT
@enduml


Commenting out the group fixes it:


@startuml
' rectangle "Group Header" as GH {
    rectangle "Group Rect 1" as AM
    rectangle "Group Rect 2" as RECT2
' }
rectangle "Input" as INPT
rectangle "Output" as OUT
rectangle "Common Output" as COUT

INPT -right-> RECT2
RECT2 -right-> OUT
RECT2 -up-> AM
RECT2 -up-> COUT
AM -up-> COUT
@enduml

Is this fixable? Or is the positioning of elements simply best effort?

1 Answer

0 votes
answered May 23 by The-Lu (10,120 points)
selected May 23 by japearson
 
Best answer

Hello J.,

As a workaround, we can use the keyword 'together'.

See 'together':

With that, we can obtain the expected result:

If that can help,
Regards,
Th.

commented May 23 by japearson (120 points)
Thanks, this is super useful to know.
...