Skip to content

Commit

Permalink
draw activations even without explicit deactivation
Browse files Browse the repository at this point in the history
  • Loading branch information
asn committed Apr 11, 2024
1 parent 3ccfea8 commit 6d54462
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/mermaid/src/diagrams/sequence/sequenceRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1050,9 +1050,22 @@ export const draw = async function (_text: string, id: string, _version: string,
for (const e of messagesToDraw) {
await drawMessage(diagram, e.messageModel, e.lineStartY, diagObj);
}

// all remaining activations in 'bounds' were not drawn, because the 'deactivate' is missing -> draw them from the activation y until the bottom / the destroying of the actor
for (const notDrawnActivation of bounds.activations) {
let stopY = bounds.getVerticalPos();
const actorToDeactivate = bounds.models.actors.find((actor) => actor.name == notDrawnActivation.actor)
if (actorToDeactivate.stopy) { // if actor was destroyed -> use it's last y
stopY = actorToDeactivate.stopy;
}

svgDraw.drawActivation(diagram, notDrawnActivation, stopY, conf, actorActivations(notDrawnActivation.actor).length);
}

if (conf.mirrorActors) {
await drawActors(diagram, actors, actorKeys, true);
}

backgrounds.forEach((e) => svgDraw.drawBackgroundRect(diagram, e));
fixLifeLineHeights(diagram, actors, actorKeys, conf);

Expand Down
2 changes: 2 additions & 0 deletions packages/mermaid/src/docs/syntax/sequenceDiagram.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ sequenceDiagram
John-->>-Alice: I feel great!
```

If no deactivation is found for an activated actor, it is still added to the diagram.

## Notes

It is possible to add notes to a sequence diagram. This is done by the notation
Expand Down

0 comments on commit 6d54462

Please sign in to comment.