Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: SequenceDiagram: draw activations even without explicit deactivation #5457

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/mermaid/src/diagrams/sequence/sequenceRenderer.ts
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
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